Code Macro Configuration Properties

Last modified by Vincent Massol on 2026/11/12 19:10

Reference

The "code" Macro is configured in xwiki/WEB-INF/xwiki.properties, in its "Rendering" section. Both properties ship commented out, showing their default value, so a property only takes effect once its line is uncommented. XWiki reads the file when it starts: restart it after a change.

PropertyDefaultDescription
rendering.macro.code.pygments.styledefaultThe colours of the highlighting, as the name of a Pygments style, such as colorful or monokai. default is not Pygments' style of that name but an XWiki style with a higher contrast. A name Pygments doesn't know falls back to Pygments' own default style.
rendering.macro.code.source.attachmentMaximumSize1000000The largest attachment, in bytes, that the source parameter of the macro accepts. A larger one makes the macro display an error instead of the code.

The Pygments style gallery shows what each style looks like. Here is some code with the default style:

Python code highlighted with the default style

The same code with the colorful style:

The same Python code highlighted with the colorful style

Warning

A style only sets the colours of the code, not the background of the block, which keeps the light colour of the skin. With a dark style, such as monokai, the code becomes hard to read:

Light-coloured code on a light background, hard to read, with the monokai style

For example, to use the colorful style and accept attachments of up to 5 MB:

rendering.macro.code.pygments.style = colorful
rendering.macro.code.source.attachmentMaximumSize = 5000000

Related

Get Connected