Coding

Content related to coding, of all languages and topics.

Code Highlighting with Prism in Drupal

Posted on 2019-03-31

If you find the need to display code snippets in your content, it's relatively easy in HTML5 to display this content as <code> elements. Beyond basic styling, though, usable code highlighting is often best accomplished with Javascript frameworks rather than CSS alone.

Among the better options is Prism.js, which in addition to being lightweight code-wise, gives a number of options on how you may wish to present code. Furthermore, if you need to remove it from your project at a later time, your underlying content won't be affected.