Skip to content

Tweaked the prompts of console code blocks #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Renderers/CodeNodeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function render(): string
}

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

$numOfLines = \count(preg_split('/\r\n|\r|\n/', $highlightedCode));
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/expected/blocks/code-blocks/terminal.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
2</pre>
<pre class="codeblock-code">
<code>
<span class="hljs-prompt">$</span> cowsay
<span class="hljs-prompt">$ </span>cowsay
<span class="hljs-string">'eat more chicken'</span>
<span class="hljs-prompt">$</span> cowsay
<span class="hljs-prompt">$ </span>cowsay
<span class="hljs-string">'mmmm'</span>
</code>
</pre>
Expand All @@ -27,7 +27,7 @@
3</pre>
<pre class="codeblock-code">
<code>
<span class="hljs-prompt">C:\&gt;</span> CIV
<span class="hljs-prompt">C:\&gt; </span>CIV
<span class="hljs-comment"># Civilization for DOS - my first computer game!</span>
</code>
</pre>
Expand Down