Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

highlight.js Input Filter

406 sites Security covered Drupal 10–11
View on drupal.org

This module integrates Highlight.js with CKEditor 5 to automatically add syntax highlighting to code snippets within your Drupal content. It offers customizable themes, a code copy button, and supports over 250 programming languages for enhanced readability of technical content.

The Highlight.js Input Filter module for Drupal integrates the popular highlight.js JavaScript library with the CKEditor 5 rich text editor, providing automatic syntax highlighting for code snippets in Drupal content. This module enhances the readability and presentation of programming code, markup, and other technical content within CKEditor fields, and has the potential to support over 250 programming languages.*

Ideal for websites that feature technical content, tutorials, developer documentation, or educational resources, the highlight.js Input Filter module ensures that code snippets are displayed in a professional, clean, and easily understandable way without the need for manual styling or complex setups.

Key features of this module include:

  • Automatic Syntax Highlighting:
    Code blocks are automatically highlighted using highlight.js when embedded within CKEditor 5 content fields with the following markup.

    <pre><code class="langauge-*">

  • Customizable Themes:
    Easily switch between various highlight.js themes to match your website’s design and aesthetic needs, offering complete flexibility in the presentation of code.
  • Code Copy Button:
    Add a convenient button that allows users to copy the code snippet to their clipboard with a single click, making it easier for visitors to use and share code examples.
  • Multiple filter formats:
    Include multiple fields with filter formats enabled on the page, and all code blocks are highlighted appropriately.
  • Efficient Resource Loading:
    The module optimizes performance by only loading the relevant highlight.js styles for the programming languages used in each CKEditor 5 enabled field. This ensures faster page loads and minimal bloat, as only the necessary styles are loaded.
  • Supports Over 250 Programming Languages:
    Whether it’s JavaScript, PHP, Python, HTML, CSS, Ruby, SQL, Java, or any other supported programming language, your code snippets will always be highlighted correctly.*
  • Seamless Integration:
    Fully integrated with CKEditor 5 and Drupal, this module requires minimal configuration, making it simple for developers and content creators to get started with code highlighting right away.

Configuration

  1. Navigate to Configuration > Content Authoring > Text formats and editors.
  2. Click the configure button next to the filter format for which you want to enable syntax highlighting.
  3. Ensure the Text editor field has CkEditor 5 selected.
  4. Within the Toolbar configuration section, drag the Code Block button from Available buttons to the Active toolbar.
  5. Under the CKEditor 5 plugin settings section, click the Code Block tab, and modify the list of pragramming languages available for the text format.
  6. Under Enable filters, check the box next to Highlight code using highlight.js.
  7. Save the text format configuration.

The highlight.js theme can be configured on the module settings page at Configuration > Content Authoring > highlight.js Input Filter settings. Visit the highlight.js Examples page to see each theme in action.

The code copy button is enabled by default, but can be disabled from the module settings page.

Usage

  1. Add a new, or edit an existing, entity which has a formatted field and has the Highlight code using highlight.js input filter enabled.
  2. Click the dropdown arrow on the Code Block button to select a language and insert a code block.
  3. Add code.
  4. Save and view the entity.

*Not all programming languages supported by highlight.js are available with this module yet due to complications described in issue #3401537. If you need a language supported, please create an issue.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Oct 2024
Latest release
4 weeks ago
Releases (12 mo)
4 ▲ from 1
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
2.0.0 Stable 10–11 Aug 1, 2026
1.2.0 Stable 9–11 Jul 31, 2026
1.1.6 Stable 9–11 Oct 6, 2025
1.1.x-dev Dev 9–11 Oct 6, 2025
1.1.5 Stable 9–11 Oct 23, 2024