implement getCode method

This commit is contained in:
yggverse 2024-04-12 11:52:33 +03:00
parent 482106edf4
commit 3265add74a
2 changed files with 16 additions and 0 deletions

View File

@ -129,6 +129,7 @@ $body = new \Yggverse\Gemini\Gemtext\Body(
#### Body::getH2
#### Body::getH3
#### Body::getQuote
#### Body::getCode
#### Body::getLinks
``` php

View File

@ -111,6 +111,21 @@ class Body
return $matches;
}
public function getCode(): array
{
$matches = [];
foreach ($this->_lines as $index => $line)
{
if (preg_match('/^```(.*)/', trim($line), $match))
{
$matches[$index] = empty($match[1]) ? null : trim($match[1]);
}
}
return $matches;
}
public function findLinks(string $protocol = 'gemini'): array
{
$matches = [];