Prism.js is a lightweight, extensible syntax highlighter, built with modern web standards in mind. Use this module to add code syntax highlighting to your Drupal content.

The module provides a couple of options for adding syntax highlighting:

  • A "Highlight code using prism.js" filter that can be added to any text formatter. And will allow highlighting of both custom [prism][/prism] code blocks. And standard <pre><code class="langauge-*"> blocks. The filter plays nicely with other filters that create code blocks as well. For example Markdown's ``` code fences.
  • A "Prism.js" field that can be added to any fieldable entity. Each field instance consists of a textarea and the option to choose a language to use for syntax highlighting.

Requirements

This module requires both the prism.js and prism.css be downloaded and installed:

  • For Drupal 8+ the files should go in /libraries/prism/*
  • For Drupal 7 the files should go in sites/all/libraries/prism/*

The Prism library should be download from http://prismjs.com/download.html. You can customize the downloaded prism.js and prism.css files to your specific use-case using the tool available on the Prism.js website. For example if you want additional languages, or a different theme, choose the options in the download tool and then install the resulting prism.js and prism.css files in your Drupal project.

Supporting organizations: 
Update for Drupal 8 & 9 + ongoing maintenance

Project information

Releases