mirror of
https://github.com/YGGverse/gemini-php.git
synced 2025-01-29 16:24:13 +00:00
fix raw lines parsing
This commit is contained in:
parent
19af7bb299
commit
5d79b18cf9
@ -181,20 +181,24 @@ class Reader
|
|||||||
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
|
||||||
if (!$raw && preg_match('/<(code|file)([^>])*>/i', $line, $matches))
|
if (!$raw && preg_match('/<(code|file)([^>]*)>/i', $line, $matches))
|
||||||
{
|
{
|
||||||
// Prepend tag meta or filename as plain description
|
// Prepend tag meta or filename as plain description
|
||||||
if (!empty($matches[0]))
|
if (!empty($matches[0]))
|
||||||
{
|
{
|
||||||
$lines[] = preg_replace(
|
$lines[] = preg_replace(
|
||||||
'/^<.*\s(.+)>$/',
|
'/<(code|file)[\s-]*([^>]*)>/i',
|
||||||
'$1',
|
'$2',
|
||||||
$matches[0]
|
$matches[0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines[] = '```';
|
$lines[] = '```';
|
||||||
$lines[] = $line;
|
$lines[] = preg_replace(
|
||||||
|
'/<(code|file)[^>]*>/i',
|
||||||
|
'',
|
||||||
|
$line
|
||||||
|
);
|
||||||
|
|
||||||
$raw = true;
|
$raw = true;
|
||||||
|
|
||||||
@ -213,7 +217,12 @@ class Reader
|
|||||||
|
|
||||||
if ($raw && preg_match('/<\/(code|file)>/i', $line))
|
if ($raw && preg_match('/<\/(code|file)>/i', $line))
|
||||||
{
|
{
|
||||||
$lines[] = $line;
|
$lines[] = preg_replace(
|
||||||
|
'/<\/(code|file)>/i',
|
||||||
|
'',
|
||||||
|
$line
|
||||||
|
);
|
||||||
|
|
||||||
$lines[] = '```';
|
$lines[] = '```';
|
||||||
|
|
||||||
$raw = false;
|
$raw = false;
|
||||||
@ -251,11 +260,9 @@ class Reader
|
|||||||
return preg_replace(
|
return preg_replace(
|
||||||
'/[\n\r]{2,}/',
|
'/[\n\r]{2,}/',
|
||||||
PHP_EOL . PHP_EOL,
|
PHP_EOL . PHP_EOL,
|
||||||
strip_tags(
|
implode(
|
||||||
implode(
|
PHP_EOL,
|
||||||
PHP_EOL,
|
$lines
|
||||||
$lines
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user