Prism.js Macro
Last modified by Vincent Massol on 2025/07/09 11:57
![]() | 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 here
Parameters 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.
Release Notes
v1.2.1
v1.2
v1.1
v1.0.1
v1.0
Dependencies
Dependencies for this extension (org.xwiki.contrib.prismjs:prismjs-macro 1.2.1):
- 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