Insert a Code Block with the BlockNote Editor
Last modified by Marius Dumitru Florea on 2026/10/19 12:00
Content
Steps
To insert a code block with the BlockNote editor:
- Type /code and select "Code Block" in the "slash menu".

Alternatively, type three backticks followed by the language and a space, for instance ```python.
- Type or paste the code.
- Hover the code block, then select the language of the code in the selector shown in its top left corner. XWiki 18.9.0+ The language selector was added, and the code is highlighted according to the selected language.

- Save the Page. The code is displayed with the syntax highlighting of its language, as follows:

FAQ
Can I edit code inserted with the Code Macro?
XWiki 18.9.0+ Yes. A standalone Code Macro, as opposed to an inline one, is displayed as a code block: edit its code in place and change its language with the selector, its other parameters are kept when the Page is saved.
Why is some code still displayed as a Macro?
XWiki 18.9.0+ An inline Code Macro, or one taking its code from the source parameter, stays a Macro: change it from the Macro edit modal.
What does the "Plain Text" language do?
XWiki 18.9.0+ The code is saved without a language, so the Code Macro guesses the language of the code when the Page is viewed.