There are several cases when we would want our code written in various programming languages (including UNIX commands and Makefiles) to have the same syntax highlighting that a code editor or IDE will have so the people who read your blog, web app or website will be able to distinguish the various keywords and elements of the language the code is written on. These blocks of code go inside a
code (inside a
The features include 166 languages and 77 styles, automatic language detection, multi-language code highlighting, available for node.js, works with any markup, compatible with any JS framework and is pretty much one of the leaders among with PrismJS. Today this project is still well maintained, the last update was 5 days ago.
It’s the one I’m currently running (Hexo, the static site genrator uses it), it has several styles but for some reason the theme I’m using chose the worst (similar to the original Github style) and two nice features: you can add a file title and the link to that file if you want. Example:
(ns project.core (:require [clojure.string :refer [split capitalize]])) ;; This is a nice comment (defn the-truth [lang] (-> (str lang " is amazing!") (split #" ") (#(map capitalize %)) (#(doseq [word %] (println word))))) (the-truth "Clojure")
This is the library currently beign used to display these code blocks; the funky style is probably my favorite.
The name gives it all away, this one has line numbers and they provide you separate files called brushes for each of the 23 (for now) languages, you may want to read the installation and integration pages to know how to use, apart of course from the download page. Check them on Github too.