diff --git a/src/Renderers/CodeNodeRenderer.php b/src/Renderers/CodeNodeRenderer.php index b3625a9..2812d71 100644 --- a/src/Renderers/CodeNodeRenderer.php +++ b/src/Renderers/CodeNodeRenderer.php @@ -74,6 +74,11 @@ public function render(): string $highlightedCode = str_replace('$', '$', $highlightedCode); } + if ('terminal' === $language) { + $highlightedCode = preg_replace('/^\$/m', '$', $highlightedCode); + $highlightedCode = preg_replace('/^C:\\\>/m', 'C:\>', $highlightedCode); + } + $numOfLines = \count(preg_split('/\r\n|\r|\n/', $highlightedCode)); $lines = implode("\n", range(1, $numOfLines - 1)); diff --git a/tests/fixtures/expected/blocks/code-blocks/terminal.html b/tests/fixtures/expected/blocks/code-blocks/terminal.html index 6bde18a..bde9415 100644 --- a/tests/fixtures/expected/blocks/code-blocks/terminal.html +++ b/tests/fixtures/expected/blocks/code-blocks/terminal.html @@ -15,5 +15,34 @@ +
+
+
1
+2
+
+           
+               $ cowsay
+               'eat more chicken'
+               $ cowsay
+               'mmmm'
+           
+       
+
+
+ +
+
+
1
+2
+3
+
+           
+               C:\> CIV
+               # Civilization for DOS - my first computer game!
+           
+       
+
+
+ - \ No newline at end of file + diff --git a/tests/fixtures/source/blocks/code-blocks/terminal.rst b/tests/fixtures/source/blocks/code-blocks/terminal.rst index 295a151..ede3e22 100644 --- a/tests/fixtures/source/blocks/code-blocks/terminal.rst +++ b/tests/fixtures/source/blocks/code-blocks/terminal.rst @@ -1,3 +1,14 @@ .. code-block:: terminal git clone git@github.com:symfony/symfony.git + +.. code-block:: terminal + + $ cowsay 'eat more chicken' + $ cowsay 'mmmm' + +.. code-block:: terminal + + C:\> CIV + + # Civilization for DOS - my first computer game!