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

Show last authors
1 The [["code" Macro>>doc:documentation.xs.user.base.page.edit.formatting.code-macro.WebHome]] 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.
2
3 |=Property|=Default|=Description
4 |##rendering.macro.code.pygments.style##|##default##|The 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.
5 |##rendering.macro.code.source.attachmentMaximumSize##|##1000000##|The 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.
6
7 The [[Pygments style gallery>>https://pygments.org/styles/]] shows what each style looks like. Here is some code with the ##default## style:
8
9 {{image reference="code-macro-style-default.png" size="large" alt="Python code highlighted with the default style"/}}
10
11 The same code with the ##colorful## style:
12
13 {{image reference="code-macro-style-colorful.png" size="large" alt="The same Python code highlighted with the colorful style"/}}
14
15 {{warning}}
16 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:
17
18 {{image reference="code-macro-style-monokai.png" size="large" alt="Light-coloured code on a light background, hard to read, with the monokai style"/}}
19 {{/warning}}
20
21 For example, to use the ##colorful## style and accept attachments of up to 5 MB:
22
23 {{code language="properties"}}
24 rendering.macro.code.pygments.style = colorful
25 rendering.macro.code.source.attachmentMaximumSize = 5000000
26 {{/code}}

Get Connected