mirror of
https://github.com/YGGverse/gemini-php.git
synced 2025-03-13 06:01:58 +00:00
implement getCode method
This commit is contained in:
parent
482106edf4
commit
3265add74a
@ -129,6 +129,7 @@ $body = new \Yggverse\Gemini\Gemtext\Body(
|
||||
#### Body::getH2
|
||||
#### Body::getH3
|
||||
#### Body::getQuote
|
||||
#### Body::getCode
|
||||
#### Body::getLinks
|
||||
|
||||
``` php
|
||||
|
@ -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 = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user