"prism" Macro
Last modified by Vincent Massol on 2026/10/20 16:30
Content
Reference
Description
The prism macro displays code with syntax highlighting, using Prism.js. In the macro list of the editors it appears as "Prism", in the "Formatting" category.
Usage
{{prism language="<language identifier>"}}
The code to highlight.
{{/prism}}The content is displayed exactly as written: it isn't parsed as wiki content, and HTML in it is shown as text.
The macro works standalone as well as inline: written on its own it renders a code block, written inside a paragraph it highlights the code inside the sentence.
Parameters
| Name | Mandatory | Allowed Values | Default Value | Description |
|---|---|---|---|---|
| content | no | text | "" | The code to highlight. Ignored when source is set. |
| language | no | a Prism.js language identifier | none | The language of the code. none or an identifier Prism.js doesn't know displays the code without highlighting. |
| layout | no | plain, linenumbers | plain | linenumbers displays line numbers in front of each line. It has no effect inline. |
| source | no | script:<variable>, string:<text> | none | The code to highlight instead of the content: the value of a script variable, or the given text. Works like the source parameter of the Code Macro. |
Generated HTML
The macro outputs the following HTML:
- standalone: <pre><code class="language-<language>">…</code></pre>, with class="line-numbers" on pre for the linenumbers layout;
- inline: <code class="language-<language>">…</code>.
Examples
Code From a Script Variable
{{velocity}}
#set ($myCode = "SELECT * FROM users WHERE id = 1;")
{{/velocity}}
{{prism language="sql" source="script:myCode"/}}
Code Inside a Sentence
Call {{prism language="javascript"}}document.querySelector('#main'){{/prism}} to get the main element.
FAQ
Why isn't my code highlighted?
Check that the language identifier is one Prism.js supports, and that JavaScript is enabled in the browser: the highlighting is done there.