Insert a Code Block with the BlockNote Editor

Last modified by Marius Dumitru Florea on 2026/10/19 12:00

Steps

To insert a code block with the BlockNote editor:

  1. Type /code and select "Code Block" in the "slash menu".

    The slash menu of the BlockNote editor with /code typed and the Code Block entry highlighted

    Alternatively, type three backticks followed by the language and a space, for instance ```python.

  2. Type or paste the code.
  3. 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.

    A code block of the BlockNote editor holding a Python function, with its language selector set to Python highlighted

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

    The saved Page displaying the Python function with syntax highlighting

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.

Related

Get Connected