Prism.js Macro
Last modified by Admin on 2026/02/26 15:33
| Syntax highlighting Macro based on Prism.js |
| Type | JAR |
| Category | Macro |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
| Compatibility | XWiki 16.10.0+ |
Table of contents
Description
See https://prismjs.com/#supported-languages for the list of all supported languages.
Usage
The macro can work both in inline mode or standalone mode.
Standalone mode:
{{prism language=<languageid>}}
... code here...
{{/prism}}Inline mode:
Some content {{prism language=<languageid>}}... code here...{{/prism}} other possible content hereParameters definition
| Name | Optional | Allowed values | Default value | Description |
|---|---|---|---|---|
| language | yes | a string | none, meaning no highlighting | The language identifier of the provided code snippet. |
| layout | yes |
| plain | The layout to apply to the code. |
| source | yes | See source reference (works the same as the Code Macro) | No default value | The reference of a content to highlight instead of the macro content. |
Examples
Java with Line Numbers
Input:
{{prism language="java" layout="linenumbers"}}
@Component
@Named("prism")
@Singleton
public class PrismMacro extends AbstractMacro<PrismMacroParameters>
{
}
{{/prism}}Result:

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).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Versions
Dependencies
Dependencies for this extension (org.xwiki.contrib.prismjs:prismjs-macro 1.2.3):
- org.apache.commons:commons-lang3 3.17.0
- org.xwiki.rendering:xwiki-rendering-api 16.10.0
- org.xwiki.rendering:xwiki-rendering-transformation-macro 16.10.0
- org.xwiki.platform:xwiki-platform-skin-api 16.10.0
- org.xwiki.platform:xwiki-platform-webjars-api 16.10.0
- org.webjars.npm:prismjs 1.30.0
- org.xwiki.platform:xwiki-platform-rendering-macro-code 16.10.0