Browse Source

implement getCode method

main
yggverse 9 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( @@ -129,6 +129,7 @@ $body = new \Yggverse\Gemini\Gemtext\Body(
#### Body::getH2
#### Body::getH3
#### Body::getQuote
#### Body::getCode
#### Body::getLinks
``` php

15
src/Gemtext/Body.php

@ -111,6 +111,21 @@ class Body @@ -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…
Cancel
Save