cogProvides code highlighting using Highlight.JS
TypeXAR
Developed by

Vincent Massol

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1
Installable with the Extension Manager

Description

Uses Highlight.JS to highlight code snippets.

Compared to the Code Macro:

  • Pros
    • Much faster on server side
  • Cons
    • Works with Javascript and thus you won't get colorized code in WYSIWYG edit mode (because the editor doesn't load the JavaScript code) or when exporting the page to PDF for example
    • Less syntaxes supported

Usage

{{highlight language="language id" style="style id"}}
... code snippet here...
{{/highlight}}

where:

Parameter NameMandatory?Description
language idNoThe language of your code snippet (see available languages). If not specified, it's auto-discovered.
style idNoThe style to use (see available styles). Default style is default.

Example

Example with default style:

highlight.png

Example with zenburn style:

highlight2.png

Tested on

This extension has been tested with the following configurations.

Extension VersionXWiki FlavorNotes
1.3XWiki Enterprise 6.0.1, 6.4.2, 7.1.2

Styles are not working well

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:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Release Notes

v1.3

  • Bugfix: HTML needs to be escaped

v1.2

  • Fixed bug with default style
  • Uses monospace font now

v1.1

  • Improved performance by only loading the JS/CSS for pages using the macro
  • Added support for styles

v1.0

First version

Tags: presentation
Created by Vincent Massol on 2013/03/11 18:12
    

Get Connected