|
|
@ -161,10 +161,17 @@ class Reader |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Convert DokuWiki text to Gemini |
|
|
|
// Convert DokuWiki text to Gemini |
|
|
|
public function toGemini(string $data, ?array &$lines = []): string |
|
|
|
public function toGemini(?string $data, ?array &$lines = []): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (empty($gemini)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$raw = false; |
|
|
|
$raw = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$lines = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ((array) explode(PHP_EOL, $data) as $line) |
|
|
|
foreach ((array) explode(PHP_EOL, $data) as $line) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Skip any formatting in lines between code tag |
|
|
|
// Skip any formatting in lines between code tag |
|
|
@ -247,9 +254,9 @@ class Reader |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getH1(string $gemini, ?string $regex = '/^[\s]?#([^#]+)/'): ?string |
|
|
|
public function getH1(?string $gemini, ?string $regex = '/^[\s]?#([^#]+)/'): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach ((array) explode(PHP_EOL, $gemini) as $line) |
|
|
|
foreach ((array) explode(PHP_EOL, (string) $gemini) as $line) |
|
|
|
{ |
|
|
|
{ |
|
|
|
preg_match( |
|
|
|
preg_match( |
|
|
|
$regex, |
|
|
|
$regex, |
|
|
@ -270,10 +277,15 @@ class Reader |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getLinks(string $gemini, ?string $regex = '/(https?|gemini):\/\/\S+/'): array |
|
|
|
public function getLinks(?string $gemini, ?string $regex = '/(https?|gemini):\/\/\S+/'): array |
|
|
|
{ |
|
|
|
{ |
|
|
|
$links = []; |
|
|
|
$links = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($gemini)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $links; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
preg_match_all( |
|
|
|
preg_match_all( |
|
|
|
$regex, |
|
|
|
$regex, |
|
|
|
$gemini, |
|
|
|
$gemini, |
|
|
|