Context
Markdown standard, is named commonmark.
Markdown markup-language is just a pre-processor to HTML, it's transpired to HTML.
Nor markdown nor HTMl supports code syntax highlight. But on fenced code blocks, an info string can be passed from markdown to HTML.
An info string can be provided after the opening code fence. Although this spec doesn’t mandate any particular treatment of the info string.
For example, this info string (ruby)…
```ruby
def foo(x)
return 3
end
```
…will be pass to HTML like this…
<pre><code class="language-ruby">def foo(x)
return 3
end
</code></pre>
… in a class attribute and prefixed with language-.
Outside proving a class that can be used in CSS, this does nothing. To obtain code syntax highlight, you need to use a syntax highlight library that can either be handled on the backend (server-side) and rendered into the HTML directly, or a front-end (client-side) JavaScript library that colors the code in the web browser.
So the reference code you put into the info string DEPENDS on the syntax highlight library you'll use.
Libraries
There are :
sh, bash, zsh, fish, ksh and so on for the content of a script so usually commands with the internal syntax of the shell language.
shell or similar for CLI commands, highlighting with different colors the main command sub-commands, arguments, strings, etc.
console, shellsession, bash session or similar for shell sessions (prompt + command + output)
For shell sessions, here are the common references for the most common syntax highlight libraries:
- Rouge (github)) uses
console.
- linguist uses
ShellSession, bash session, console.
- GitHub and it's non-standard GFM (GitHub flavored Markdown) uses their own library named linguist for what is used all comments and descriptions in issues, pull request, descriptions, etc.
- Highlight.js (doc) has nothing for shell sessions.
- but has
shell and console for CLI commands.
- Prism.js uses
shell-session, sh-session, shellsession.
- Here
shell is an alias for bash and sh.
- EnlighterJS has nothing for shell sessions.
- Here
shell is an alias for bash.
- Chroma has something called
Session.
- Pygments (doc) uses
console, shell-session for bash sessions, pwsh-session, ps1con for power shell sessions and many other non-shell sessions are supported too like interpreter of may languages.
- Torchlight (doc) has nothing for shell sessions.
- but has
shell for CLI commands.
Plugins
Some markdown rendering engine or syntax highlighter have some extensions / plugins to renders prompt, command and outputs separately like Prism.js Command Line plugin.
Other features
Some like Bright brings some features like tab icon, titles, etc.. Some have native features to add numbering, highlight a line, etc.
```shellor```bash