Skip to content

Commit f0cf6f2

Browse files
committed
minor #103 Tweaked the prompts of console code blocks (javiereguiluz)
This PR was merged into the main branch. Discussion ---------- Tweaked the prompts of console code blocks In code blocks that are consoles, we tweak the prompt a bit to make it not selectable. However, there's an extra white space. See: ![](https://user-images.githubusercontent.com/121003/124131097-7712f480-da4d-11eb-8b07-781fbfa6f2cb.png) This PR changes it to look like this: ![](https://user-images.githubusercontent.com/73419/124267411-7f942980-db38-11eb-9222-fe07b9b80ac8.png) Commits ------- c38cd89 Tweaked the prompts of console code blocks
2 parents a90dd3b + c38cd89 commit f0cf6f2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Renderers/CodeNodeRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function render(): string
7474
}
7575

7676
if ('terminal' === $language) {
77-
$highlightedCode = preg_replace('/^\$/m', '<span class="hljs-prompt">$</span>', $highlightedCode);
78-
$highlightedCode = preg_replace('/^C:\\\&gt;/m', '<span class="hljs-prompt">C:\&gt;</span>', $highlightedCode);
77+
$highlightedCode = preg_replace('/^\$ /m', '<span class="hljs-prompt">$ </span>', $highlightedCode);
78+
$highlightedCode = preg_replace('/^C:\\\&gt; /m', '<span class="hljs-prompt">C:\&gt; </span>', $highlightedCode);
7979
}
8080

8181
$numOfLines = \count(preg_split('/\r\n|\r|\n/', $highlightedCode));

tests/fixtures/expected/blocks/code-blocks/terminal.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
2</pre>
1212
<pre class="codeblock-code">
1313
<code>
14-
<span class="hljs-prompt">$</span> cowsay
14+
<span class="hljs-prompt">$ </span>cowsay
1515
<span class="hljs-string">'eat more chicken'</span>
16-
<span class="hljs-prompt">$</span> cowsay
16+
<span class="hljs-prompt">$ </span>cowsay
1717
<span class="hljs-string">'mmmm'</span>
1818
</code>
1919
</pre>
@@ -27,7 +27,7 @@
2727
3</pre>
2828
<pre class="codeblock-code">
2929
<code>
30-
<span class="hljs-prompt">C:\&gt;</span> CIV
30+
<span class="hljs-prompt">C:\&gt; </span>CIV
3131
<span class="hljs-comment"># Civilization for DOS - my first computer game!</span>
3232
</code>
3333
</pre>

0 commit comments

Comments
 (0)