Code macro

Back to Available macros

The Code macro highlights source code. The syntax-highlighting is carried out by the Pygments library. If you want to specifically highlight C++ code, then you should look at CppCode macro for additional features.

Properties

Output expansion default

Disabled.

Parameters

The source code to highlight.

Variables

Code.type
The type of the code. You may provide any of the Pygments lexer names available here. If this variable is empty, then the code-type is guessed from the content by Pygments. If the guessing fails, then the lexer is assumed to be the text lexer. The guessing is not very reliable, so explicit specification should be favored. Default: Empty.

Warnings

invalid-input
This warning is generated when the type is not recognized by Pygments.

Example

[[set Code.type]]: python
[[Code]]:
    def square(x):
        return x * x
def square(x):
    return x * x

Files

Code macro

Generates colored html from many kinds of source code.