mirror of
https://github.com/kevachat/webapp.git
synced 2025-01-22 12:34:25 +00:00
add markdown filter
This commit is contained in:
parent
efbef3a41c
commit
20039728f0
@ -326,6 +326,33 @@ class AppExtension extends AbstractExtension
|
|||||||
string $text
|
string $text
|
||||||
): string
|
): string
|
||||||
{
|
{
|
||||||
|
$lines = [];
|
||||||
|
|
||||||
|
foreach (explode(PHP_EOL, $text) as $line)
|
||||||
|
{
|
||||||
|
$lines[] = preg_replace(
|
||||||
|
[
|
||||||
|
'/^(\s?)([#]{1,6})(.*)/',
|
||||||
|
'/^(\s?)([*]+)(.*)/',
|
||||||
|
'/^(\s?)([`]+)(.*)/',
|
||||||
|
'/^(\s?)([\d]+\.)(.*)/',
|
||||||
|
'/^(\s?)(>)(.*)/',
|
||||||
|
'/(\s?)(!)(.*)/',
|
||||||
|
'/(\s?)(\[)(.*)/',
|
||||||
|
'/(\s?)(\])(.*)/',
|
||||||
|
'/(\s?)(\()(.*)/',
|
||||||
|
'/(\s?)(\))(.*)/',
|
||||||
|
],
|
||||||
|
'$1\\\$2$3',
|
||||||
|
$line
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = implode(
|
||||||
|
PHP_EOL,
|
||||||
|
$lines
|
||||||
|
);
|
||||||
|
|
||||||
$text = $this->urlToMarkdown(
|
$text = $this->urlToMarkdown(
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user