Skip to content

Add syntax highlighting to improve code usability #707

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

Open
deniak opened this issue Jan 24, 2025 · 0 comments
Open

Add syntax highlighting to improve code usability #707

deniak opened this issue Jan 24, 2025 · 0 comments

Comments

@deniak
Copy link
Member

deniak commented Jan 24, 2025

Describe the issue
Some of our pages list a lot of commands and code but with the current style, it can be difficult to visualize these.
For instance, if we use code from markdown, the following markup will be generated:

<p>simple command</p>

<p><code class="language-plaintext highlighter-rouge">echo "Hello World"</code></p>

<p>JS code</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">function</span> <span class="nx">sayHello</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="dl">'</span><span class="s1">Hello World</span><span class="dl">'</span><span class="p">);</span>
  <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">`Hello </span><span class="p">${</span><span class="nx">name</span><span class="p">}</span><span class="s2">`</span><span class="p">);</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<p>another type of commands: <code class="language-plaintext highlighter-rouge">foo bar</code></p>

Screenshot of the result

Image

Using syntax highlighting and added a background color to code, samp and kbd would greatly improve the visibility, e.g.

Image

Given that pages containing code will likely be generated from markdown files using jekyll, it may make sense to use one of the jekyll syntax highlight styles. FYI, I used monokai.sublime from https://github.com/mzlogin/rouge-themes/tree/master/dist to generate the above.

@vivienlacourba vivienlacourba changed the title Add syntax highlighting Add syntax highlighting to improve code usability Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 To do
Development

No branches or pull requests

1 participant