Syntax Highlighting Common Library
![]() | Provides a Syntax Highlighting library |
Type | XAR |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
- Provides a RequireJS module to initialize CodeMirror editors in XWiki
- Basic addons are added autoatically to the editor. Other CodeMirror addons can be added by the user
- Choose the theme of the editor
How to use
require([syntaxHighlightingPath], function(SH) {
// Change the theme of the future CodeMirror editors initialized
SH.setTheme('ambiance');
// Transform a textarea into a CodeMirror editor
SH.initCodeMirror('#textareaId', 'css');
// Transform a textarea into a CodeMirror editor
SH.initCodeMirror('#textareaId2', 'javascript', [
['SyntaxHighlighting_cm/addon/display/placeholder'],
{lineWrapping : true}
]);
});
Available methods
- setTheme(String themeName)
- themeName : See the list of available themes and their rendering here
- initCodeMirror(String cssSelector, String mode [, Array<String, Object> addons])
- cssSelector : A cssSelector representing all the textareas that have to be transformed into CodeMirror editors
- mode : The language used in the editor. See the full list of available languages. You can also use "xwiki/2.0" or "xwiki/2.1" which add support the the velocity, groovy, python or html macros in addition to the wiki syntax tags.
- addons : An array componed of <Array<String> requireURL, Object parameters> elements.
- requireURL : A array of URL to load the addons enabling the parameters in the webjar, starting with "SyntaxHighlighting_cm/". e.g. : ['SyntaxHighlighting_cm/addon/display/placeholder']
- parameter : An object {parameter1 : 'value', parameter2 : 'value'}
Release Notes
4.6.1
The following translations have been updated with this release:
4.6
4.5.2
4.5.1
4.5
4.4
4.3.1
4.3
4.2
4.1
4.0
3.4
3.3
3.2
3.1.1
3.1
3.0
2.2
2.1
2.0
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:
- Log in the wiki with a user having Administration rights
- Go to the Administration page and select the Import category
- Follow the on-screen instructions to upload the downloaded XAR
- Click on the uploaded XAR and follow the instructions
- You'll also need to install all dependent Extensions that are not already installed in your wiki
Dependencies
Dependencies for this extension (org.xwiki.contrib.editortool:editor-tool-highlighting-ui-code 4.6.1):
- org.webjars.npm:codemirror 5.56.0-xwiki
- org.xwiki.platform:xwiki-platform-rendering-macro-velocity 12.10
- org.xwiki.platform:xwiki-platform-webjars-api 12.10