Code Macro
This is a XWiki macro, bundled with all the XWiki products by default.
Macro developed by the XWiki Development Team.
This macro cannot currently be downloaded separately.
Macro developed by the XWiki Development Team.
This macro cannot currently be downloaded separately.
Code Macro
Highlight provided code snippet. See http://pygments.org/languages/ for the list of currently supported languages.Usage
{{code language=<providedlanguage>}}
… code here…
{{/code}}Parameters definition
| Name | Optional | Allowed values | Default value | Description |
|---|---|---|---|---|
| language | yes | a string | the macro tries to determine the syntax | the language identifier of the provided code snippet. If no language identifier is specified then the macro will try to determine the syntax. To avoid highlight you can use "none" language identifier. |
Adding new languages
Anyone can add a new language support by:- adding a XWiki java component: implementing HighlightParser interface component. See Component Module for more details on how to write component for the new XWiki 2.0 architecture
- the default org.xwiki.rendering.parser.HighlightParser is based on Pygments so the best for both projects is to provide a new syntax parser to Pygments project. See http://pygments.org/contribute/
Example
{{code language="html"}}
<html>
<head>Cool!</head>
</html>
{{/code}}Result