mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 17:05:29 +00:00
implement getCode method
This commit is contained in:
parent
482106edf4
commit
3265add74a
2 changed files with 16 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue