|
|
|
@ -105,4 +105,89 @@ class Body
@@ -105,4 +105,89 @@ class Body
|
|
|
|
|
|
|
|
|
|
return $matches; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function skipTags(array $tags = []): string |
|
|
|
|
{ |
|
|
|
|
$lines = []; |
|
|
|
|
|
|
|
|
|
foreach ($this->_lines as $line) |
|
|
|
|
{ |
|
|
|
|
$line = trim( |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($tags) |
|
|
|
|
{ |
|
|
|
|
foreach ($tags as $tag) |
|
|
|
|
{ |
|
|
|
|
if(!in_array($tag, ['#', '##', '###', '=>', '*', '```'])) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (true) |
|
|
|
|
{ |
|
|
|
|
case str_starts_with($line, '#'): |
|
|
|
|
|
|
|
|
|
$line = preg_replace( |
|
|
|
|
sprintf( |
|
|
|
|
'/^%s([^#]+)/ui', |
|
|
|
|
$tag |
|
|
|
|
), |
|
|
|
|
'$1', |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case str_starts_with($line, '*'): |
|
|
|
|
|
|
|
|
|
$line = preg_replace( |
|
|
|
|
'/^\*(.*)/ui', |
|
|
|
|
'$1', |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
$line = preg_replace( |
|
|
|
|
sprintf( |
|
|
|
|
'/^%s(.*)/ui', |
|
|
|
|
$tag |
|
|
|
|
), |
|
|
|
|
'$1', |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$line = preg_replace( |
|
|
|
|
[ |
|
|
|
|
'/^#([^#]+)/ui', |
|
|
|
|
'/^##([^#]+)/ui', |
|
|
|
|
'/^###([^#]+)/ui', |
|
|
|
|
'/^=>(.*)/ui', |
|
|
|
|
'/^\*(.*)/ui', |
|
|
|
|
'/^```(.*)/ui', |
|
|
|
|
], |
|
|
|
|
'$1', |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lines[] = trim( |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return implode( |
|
|
|
|
PHP_EOL, |
|
|
|
|
$lines |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |