mirror of
https://github.com/YGGverse/gemini-php.git
synced 2025-03-13 06:01:58 +00:00
add quote support
This commit is contained in:
parent
1b996e043b
commit
482106edf4
@ -21,62 +21,76 @@ class Pango
|
|||||||
\Yggverse\Gemini\Gemtext\Body $body
|
\Yggverse\Gemini\Gemtext\Body $body
|
||||||
): string
|
): string
|
||||||
{
|
{
|
||||||
// Format body
|
|
||||||
$lines = $body->getLines();
|
$lines = $body->getLines();
|
||||||
|
|
||||||
$escaped = [];
|
$escaped = [];
|
||||||
|
|
||||||
/// Format H1
|
// H1
|
||||||
foreach ($body->getH1() as $index => $h1)
|
foreach ($body->getH1() as $index => $value)
|
||||||
{
|
{
|
||||||
$lines[$index] = sprintf(
|
$lines[$index] = sprintf(
|
||||||
'<span size="xx-large">%s</span>',
|
'<span size="xx-large">%s</span>',
|
||||||
self::escape(
|
self::escape(
|
||||||
$h1
|
$value
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$escaped[] = $index;
|
$escaped[] = $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format H2
|
// H2
|
||||||
foreach ($body->getH2() as $index => $h2)
|
foreach ($body->getH2() as $index => $value)
|
||||||
{
|
{
|
||||||
$lines[$index] = sprintf(
|
$lines[$index] = sprintf(
|
||||||
'<span size="x-large">%s</span>',
|
'<span size="x-large">%s</span>',
|
||||||
self::escape(
|
self::escape(
|
||||||
$h2
|
$value
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$escaped[] = $index;
|
$escaped[] = $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format H3
|
// H3
|
||||||
foreach ($body->getH3() as $index => $h3)
|
foreach ($body->getH3() as $index => $value)
|
||||||
{
|
{
|
||||||
$lines[$index] = sprintf(
|
$lines[$index] = sprintf(
|
||||||
'<span size="large">%s</span>',
|
'<span size="large">%s</span>',
|
||||||
self::escape(
|
self::escape(
|
||||||
$h3
|
$value
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$escaped[] = $index;
|
$escaped[] = $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Escape entities
|
// H3
|
||||||
foreach ($lines as $index => $line)
|
foreach ($body->getH3() as $index => $value)
|
||||||
{
|
{
|
||||||
if (!in_array($index, $escaped))
|
$lines[$index] = sprintf(
|
||||||
{
|
'<span size="large">%s</span>',
|
||||||
$lines[$index] = self::escape(
|
self::escape(
|
||||||
$line
|
$value
|
||||||
);
|
)
|
||||||
}
|
);
|
||||||
|
|
||||||
|
$escaped[] = $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO links, code, escape entities
|
// Quote
|
||||||
|
foreach ($body->getQuote() as $index => $value)
|
||||||
|
{
|
||||||
|
$lines[$index] = sprintf(
|
||||||
|
'<i>%s</i>',
|
||||||
|
self::escape(
|
||||||
|
$value
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$escaped[] = $index;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @TODO links, code
|
||||||
|
|
||||||
return implode(
|
return implode(
|
||||||
PHP_EOL,
|
PHP_EOL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user