Browse Source

implement getCode method

main
yggverse 7 months ago
parent
commit
3265add74a
  1. 1
      README.md
  2. 15
      src/Gemtext/Body.php

1
README.md

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

15
src/Gemtext/Body.php

@ -111,6 +111,21 @@ class Body
return $matches; 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 public function findLinks(string $protocol = 'gemini'): array
{ {
$matches = []; $matches = [];

Loading…
Cancel
Save