Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Server-sided code highlighting

Security covered Under active development 34 sites

This module provides server-sided code highlighting for code snippets on your Drupal site using the highlight.php library. It adds a new field type that allows users to input code and select a programming language, with the highlighting processed on the server to improve performance and caching. The output can either use your theme's styling or be styled by one of the provided stylesheets.

To improve the readability of code, many text editors use language-specific syntax highlighting. This module uses the highlight.php library to offer similar functionality when displaying code snippets on your site. highlight.php itself is a port of the popular highlight.js, and allows the syntax highlighting to be done on the web-server. Instead of relying on the client to do highlighting, the advantage of server-sided code highlighting is that this allows to cache the results and not be dependent on JavaScript running in the browser.

This module introduces the "Code snippet (server-sided code highlighting)" field, which can be attached to any field-able entity (like nodes or Paragraphs). The provided widget allows to enter the code snippet in a text area and select the programming language (currently 185 languages are supported). The formatter allows indicating whether your theme styles the syntax highlighting or that one of the 94 style sheets is delivered to the browser.

Requirements

This module depends on the scrivo/highlight.php library and the contributed Vendor Stream Wrapper module. When using composer require drupal/ssch to install this module, both these dependencies should automatically be installed.

Similar projects

Drupal 10–11

Ask your assistant about Server-sided code highlighting

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Mar 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.0.2 Stable 10–11 Oct 1, 2024
2.0.1 Stable 10–11 Jul 3, 2024
2.0.0 Stable 10 Mar 10, 2024