mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
fix preformatted markup
This commit is contained in:
parent
6d37944c04
commit
5b7ff6974e
1 changed files with 125 additions and 65 deletions
|
|
@ -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(
|
||||
'<span size="xx-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
else
|
||||
{
|
||||
switch ($entity->getLevel())
|
||||
{
|
||||
case 1: // #
|
||||
|
||||
$line[] = sprintf(
|
||||
'<span size="xx-large">%s</span>',
|
||||
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(
|
||||
'<span size="x-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
$line[] = sprintf(
|
||||
'<span size="x-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case 3: // ###
|
||||
case 3: // ###
|
||||
|
||||
$line[] = sprintf(
|
||||
'<span size="large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
$line[] = sprintf(
|
||||
'<span size="large">%s</span>',
|
||||
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(
|
||||
'<a href="%s" title="%s">%s</a>',
|
||||
$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(
|
||||
'<a href="%s" title="%s">%s</a>',
|
||||
$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(
|
||||
'<i>%s</i>',
|
||||
htmlspecialchars(
|
||||
if ($preformatted)
|
||||
{
|
||||
$line[] = htmlspecialchars(
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
$entity->toString()
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$line[] = sprintf(
|
||||
'<i>%s</i>',
|
||||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue