From f8a63b0dbb8216d8188eff38bdc560e1f3327acb Mon Sep 17 00:00:00 2001 From: "lina.wolf" Date: Fri, 11 Oct 2024 19:46:45 +0200 Subject: [PATCH] [FEATURE] Create a rst theme to convert markdown Convert basic mark-down into restructured Text * blockquote --- .../src/RstTheme/Twig/RstExtension.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php b/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php index a8de185ca..5f3433e5f 100644 --- a/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php +++ b/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php @@ -22,7 +22,12 @@ use Twig\TwigFilter; use Twig\TwigFunction; +use function array_map; +use function explode; +use function implode; use function min; +use function preg_replace; +use function rtrim; use function str_repeat; use function strlen; @@ -59,12 +64,14 @@ public function cleanContent(string $content): string $content = implode("\n", $lines); $content = preg_replace('/(\n){2,}/', "\n\n", $content); - return rtrim($content)."\n"; + + return rtrim($content) . "\n"; } public function renderRstIndent(string $text, int $indentNr): string { - $indent = str_repeat(' ', $indentNr*4); + $indent = str_repeat(' ', $indentNr * 4); + return preg_replace('/^/m', $indent, $text); }