diff --git a/src/Entity/Browser/Container/Page/Content/Data.php b/src/Entity/Browser/Container/Page/Content/Data.php
index 0146bd81..3791c3c3 100644
--- a/src/Entity/Browser/Container/Page/Content/Data.php
+++ b/src/Entity/Browser/Container/Page/Content/Data.php
@@ -160,112 +160,172 @@ class Data
case $entity instanceof \Yggverse\Gemtext\Entity\Header:
- switch ($entity->getLevel())
+ if ($preformatted)
{
- case 1: // #
+ $line[] = htmlspecialchars(
+ $this->_wrap(
+ $entity->toString()
+ )
+ );
+ }
- $line[] = sprintf(
- '%s',
- htmlspecialchars(
- $this->_wrap(
- $entity->getText()
+ else
+ {
+ switch ($entity->getLevel())
+ {
+ case 1: // #
+
+ $line[] = sprintf(
+ '%s',
+ htmlspecialchars(
+ $this->_wrap(
+ $entity->getText()
+ )
)
- )
- );
+ );
- // Find and return document title by first # tag
- if (empty($title))
- {
- $title = $entity->getText();
- }
+ // Find and return document title by first # tag
+ if (empty($title))
+ {
+ $title = $entity->getText();
+ }
- break;
+ break;
- case 2: // ##
+ case 2: // ##
- $line[] = sprintf(
- '%s',
- htmlspecialchars(
- $this->_wrap(
- $entity->getText()
+ $line[] = sprintf(
+ '%s',
+ htmlspecialchars(
+ $this->_wrap(
+ $entity->getText()
+ )
)
- )
- );
+ );
- break;
+ break;
- case 3: // ###
+ case 3: // ###
- $line[] = sprintf(
- '%s',
- htmlspecialchars(
- $this->_wrap(
- $entity->getText()
+ $line[] = sprintf(
+ '%s',
+ htmlspecialchars(
+ $this->_wrap(
+ $entity->getText()
+ )
)
- )
- );
+ );
- break;
- default:
+ break;
+ default:
- throw new \Exception;
+ throw new \Exception;
+ }
}
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Link:
- $line[] = sprintf(
- '%s',
- $this->_url(
- $entity->getAddress()
- ),
- htmlspecialchars(
- $entity->getAddress()
- ),
- htmlspecialchars(
+ if ($preformatted)
+ {
+ $line[] = htmlspecialchars(
$this->_wrap(
- $entity->getAlt() ? $entity->getAlt()
- : $entity->getAddress() // @TODO date
+ $entity->toString()
)
- )
- );
+ );
+ }
+
+ else
+ {
+ $line[] = sprintf(
+ '%s',
+ $this->_url(
+ $entity->getAddress()
+ ),
+ htmlspecialchars(
+ $entity->getAddress()
+ ),
+ htmlspecialchars(
+ $this->_wrap(
+ $entity->getAlt() ? $entity->getAlt()
+ : $entity->getAddress() // @TODO date
+ )
+ )
+ );
+ }
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Listing:
- $line[] = sprintf(
- '* %s',
- htmlspecialchars(
+ if ($preformatted)
+ {
+ $line[] = htmlspecialchars(
$this->_wrap(
- $entity->getItem()
+ $entity->toString()
)
- )
- );
+ );
+ }
+
+ else
+ {
+ $line[] = sprintf(
+ '* %s',
+ htmlspecialchars(
+ $this->_wrap(
+ $entity->getItem()
+ )
+ )
+ );
+ }
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Quote:
- $line[] = sprintf(
- '%s',
- htmlspecialchars(
+ if ($preformatted)
+ {
+ $line[] = htmlspecialchars(
$this->_wrap(
- $entity->getText()
+ $entity->toString()
)
- )
- );
+ );
+ }
+
+ else
+ {
+ $line[] = sprintf(
+ '%s',
+ htmlspecialchars(
+ $this->_wrap(
+ $entity->getText()
+ )
+ )
+ );
+ }
break;
case $entity instanceof \Yggverse\Gemtext\Entity\Text:
- $line[] = htmlspecialchars(
- $this->_wrap(
- $entity->getData()
- )
- );
+ if ($preformatted)
+ {
+ $line[] = htmlspecialchars(
+ $this->_wrap(
+ $entity->toString()
+ )
+ );
+ }
+
+ else
+ {
+ $line[] = htmlspecialchars(
+ $this->_wrap(
+ $entity->getData()
+ )
+ );
+ }
break;