Changes for page Code Macro
Last modified by Admin on 2024/04/18 01:08
From version 1.48
edited by Thomas Mortagne
on 2019/04/12 14:52
on 2019/04/12 14:52
Change comment:
Add EXOExtensionCode.ExtensionClass object
To version 2.1
edited by Thomas Mortagne
on 2019/04/12 14:54
on 2019/04/12 14:54
Change comment:
There is no comment for this version
Summary
-
Objects (2 modified, 0 added, 0 removed)
Details
- EXOExtensionCode.ExtensionClass[0]
-
- Bundled With
-
... ... @@ -1,0 +1,1 @@ 1 +enterprise XWiki Standard
- ExtensionCode.ExtensionClass[0]
-
- Description
-
... ... @@ -1,1 +1,58 @@ 1 -Highlights code 1 +See http://pygments.org/languages/ for the list of all supported languages. If you have a hard time finding the right id for the language you can look at http://pygments.org/docs/lexers/#lexers-for-php-and-related-languages. 2 + 3 +{{info}} 4 +See also the [[Highlight Macro>>Extension.Highlight Macro]]. 5 +{{/info}} 6 + 7 +== Usage == 8 + 9 +{{code language="none"}} 10 +{{code language=<providedlanguage>}} 11 +... code here... 12 +{{/code}} 13 +{{/code}} 14 + 15 +=== Parameters definition === 16 + 17 +|=Name|=Optional|=Allowed values|=Default value|=Description 18 +|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. 19 + 20 +This macro also support all [[Box Macro parameters>>Box Macro||anchor="HParametersdefinition"]]. 21 + 22 +=== Configuration === 23 + 24 +It's possible to set some configuration for this macro in the ##xwiki.properties## file: 25 + 26 +|=Name|=Optional|=Allowed values|=Default value|=Description 27 +|rendering.macro.code.pygments.style (since 2.4M1)|yes|a string|##default##|the name of the Pygments style to use. See http://pygments.org/docs/styles/ for more about styles. 28 + 29 +Example: 30 + 31 +{{code language="properties"}} 32 +rendering.macro.code.pygments.style=vs 33 +{{/code}} 34 + 35 +== Adding new languages == 36 + 37 +Anyone can add a new language support by: 38 + 39 +* adding a XWiki java component: implementing {{scm path="xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-code/src/main/java/org/xwiki/rendering/parser/HighlightParser.java"}}HighlightParser interface{{/scm}} component. See [[Component Module>>Component Module]] for more details on how to write component for the new XWiki 2.0 architecture 40 +* the default ##org.xwiki.rendering.parser.HighlightParser## is based on [[Pygments>>http://pygments.org]] so the best for both projects is probably to provide a new syntax parser to [[Pygments>>http://pygments.org]] project. See [[http://pygments.org/contribute/]]. 41 + 42 +== Example == 43 + 44 +{{code language="none"}} 45 +{{code language="html"}} 46 +<html> 47 + <head>Cool!</head> 48 +</html> 49 +{{/code}} 50 +{{/code}} 51 + 52 +=== Result === 53 + 54 +{{code language="html"}} 55 +<html> 56 + <head>Cool!</head> 57 +</html> 58 +{{/code}} - Show installed count
-
... ... @@ -1,0 +1,1 @@ 1 +No