mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 08:55:28 +00:00
add links support
This commit is contained in:
parent
cef15510ea
commit
2cbdcbf255
1 changed files with 33 additions and 1 deletions
|
|
@ -138,7 +138,39 @@ class Pango
|
|||
}
|
||||
}
|
||||
|
||||
// @TODO links
|
||||
// Links
|
||||
foreach ($body->getLinks() as $index => $line)
|
||||
{
|
||||
if (!isset($raw[$index]))
|
||||
{
|
||||
$link = new \Yggverse\Gemini\Gemtext\Link(
|
||||
$line
|
||||
);
|
||||
|
||||
if (!$address = $link->getAddress())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$alt = $link->getAlt())
|
||||
{
|
||||
if (!$alt = $link->getDate())
|
||||
{
|
||||
$alt = $address;
|
||||
}
|
||||
}
|
||||
|
||||
$lines[$index] = sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
$address,
|
||||
self::escape(
|
||||
$alt
|
||||
)
|
||||
);
|
||||
|
||||
$escaped[] = $index;
|
||||
}
|
||||
}
|
||||
|
||||
// Escape special chars for non escaped lines
|
||||
foreach ($body->getLines() as $index => $value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue