fix preformatted markup

This commit is contained in:
yggverse 2024-07-14 13:54:55 +03:00
parent 6d37944c04
commit 5b7ff6974e

View file

@ -160,6 +160,17 @@ class Data
case $entity instanceof \Yggverse\Gemtext\Entity\Header:
if ($preformatted)
{
$line[] = htmlspecialchars(
$this->_wrap(
$entity->toString()
)
);
}
else
{
switch ($entity->getLevel())
{
case 1: // #
@ -210,11 +221,23 @@ class Data
throw new \Exception;
}
}
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Link:
if ($preformatted)
{
$line[] = htmlspecialchars(
$this->_wrap(
$entity->toString()
)
);
}
else
{
$line[] = sprintf(
'<a href="%s" title="%s">%s</a>',
$this->_url(
@ -230,11 +253,23 @@ class Data
)
)
);
}
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Listing:
if ($preformatted)
{
$line[] = htmlspecialchars(
$this->_wrap(
$entity->toString()
)
);
}
else
{
$line[] = sprintf(
'* %s',
htmlspecialchars(
@ -243,11 +278,23 @@ class Data
)
)
);
}
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Quote:
if ($preformatted)
{
$line[] = htmlspecialchars(
$this->_wrap(
$entity->toString()
)
);
}
else
{
$line[] = sprintf(
'<i>%s</i>',
htmlspecialchars(
@ -256,16 +303,29 @@ class Data
)
)
);
}
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Text:
if ($preformatted)
{
$line[] = htmlspecialchars(
$this->_wrap(
$entity->toString()
)
);
}
else
{
$line[] = htmlspecialchars(
$this->_wrap(
$entity->getData()
)
);
}
break;