mirror of
https://github.com/YGGverse/gemtext-php.git
synced 2026-03-31 17:55:38 +00:00
format toString separators
This commit is contained in:
parent
441dc1e50a
commit
539dc97372
5 changed files with 41 additions and 10 deletions
|
|
@ -58,6 +58,17 @@ class Code implements \Yggverse\Gemtext\Interface\Entity
|
|||
|
||||
public function toString(): string
|
||||
{
|
||||
return self::TAG . $this->_alt . ($this->_inline ? self::TAG : null);
|
||||
return $this->_inline ? sprintf(
|
||||
'%s%s%s',
|
||||
self::TAG,
|
||||
$this->_alt,
|
||||
self::TAG
|
||||
) : trim(
|
||||
sprintf(
|
||||
'%s %s',
|
||||
self::TAG,
|
||||
$this->_alt
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -65,9 +65,15 @@ class Header implements \Yggverse\Gemtext\Interface\Entity
|
|||
|
||||
public function toString(): string
|
||||
{
|
||||
return str_repeat(
|
||||
self::TAG,
|
||||
$this->_level
|
||||
) . $this->_text;
|
||||
return trim(
|
||||
sprintf(
|
||||
'%s %s',
|
||||
str_repeat(
|
||||
self::TAG,
|
||||
$this->_level
|
||||
),
|
||||
$this->_text
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -116,9 +116,11 @@ class Link implements \Yggverse\Gemtext\Interface\Entity
|
|||
$parts[] = $alt;
|
||||
}
|
||||
|
||||
return implode(
|
||||
' ',
|
||||
$parts
|
||||
return trim(
|
||||
implode(
|
||||
' ',
|
||||
$parts
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -39,6 +39,12 @@ class Listing implements \Yggverse\Gemtext\Interface\Entity
|
|||
|
||||
public function toString(): string
|
||||
{
|
||||
return self::TAG . ' ' . $this->_item;
|
||||
return trim(
|
||||
sprintf(
|
||||
'%s %s',
|
||||
self::TAG,
|
||||
$this->_item
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -39,6 +39,12 @@ class Quote implements \Yggverse\Gemtext\Interface\Entity
|
|||
|
||||
public function toString(): string
|
||||
{
|
||||
return self::TAG . ' ' . $this->_text;
|
||||
return trim(
|
||||
sprintf(
|
||||
'%s %s',
|
||||
self::TAG,
|
||||
$this->_text
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue