Highlight.js supports over 180 different languages in the core library. There are also 3rd party language plugins available for additional languages. — How to use highlight.js
In my previous blog post I added a BASIC source code, but it was not highlighted. In this case, the ‘highlighting’ is a light blue background color. The same is true for Dockerfile source code. In this case, I chose ‘text’ as language and highlighted the source code. I don’t want to use ‘text’ for all unknown languages and I also want some syntax highlighting 🎨 depending on the language. Therefore I take a closer look at highlight.js.
<link rel="stylesheet" href="/css/highlight/github.css"> <script src="/js/vendors/highlight.pack.js"></script> <script>hljs.initHighlightingOnLoad();</script>
The most complicated part was figuring out which style to select. I chose the GitHub style. For the programming languages I selected on the Download highlight.js page all Common languages and the following Other languages:
- Lisp and Scheme
- OCaml and ReasonML
There is a list of all Supported Languages. There are more languages I will write about in the future, and for these I need the appropriate syntax highlighting …