Highlight Macro

Last modified by Vincent Massol on 2023/10/02 00:25

cogProvides code highlighting using Highlight.JS
Developed by

Vincent Massol

Active Installs83
1 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager


Uses Highlight.JS to highlight code snippets.

Compared to the Code Macro:

  • Pros
    • Much faster on server side
  • Cons
    • Works with Javascript and thus you won't get colorized code in WYSIWYG edit mode (because the editor doesn't load the JavaScript code) or when exporting the page to PDF for example
      • The new in-place WYSIWYG editor loads JavaScript code so this is no longer an issue
      • The new client-side PDF export knows how to export HTML DOM changes done by JavaScript code so not an issue anymore either
    • Less syntaxes supported


{{highlight language="language id" style="style id"}}
... code snippet here...


Parameter NameMandatory?Description
language idNoThe language of your code snippet (see available languages). If not specified, it's auto-discovered.
style idNoThe style to use (see available styles). Default style is default.


Example with default style:


Example with zenburn style:


Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Release Notes


  • Bugfix: HTML needs to be escaped


  • Fixed bug with default style
  • Uses monospace font now


  • Improved performance by only loading the JS/CSS for pages using the macro
  • Added support for styles


First version

Get Connected