Statocles::Plugin::Highlight - Highlight code and configuration syntax


    # --- Configuration
    # site.yml
        class: Statocles::Site
                    $class: Statocles::Plugin::Highlight
                        style: default

    # --- Usage
    <%= highlight perl => begin %>
    print "Hello, World!\n";
    <% end %>


This plugin adds the highlight helper function to all templates and content documents, allowing for syntax highlighting of source code and configuration blocks.



The style to use, which corresponds to a stylesheet file in your theme's /plugin/highlight directory without the trailing .css. Defaults to "default", which refers to the default.css file.

The styles included by default are:

  • default

  • solarized-light

  • solarized-dark



    %= highlight $type => $content

Highlight the given $content using the given $type syntax.

The list of supported syntaxes are in the SUPPORTED SYNTAX section, below.

To highlight a block of code, use begin/end:

    %= highlight Perl => begin
    use strict;
    use warnings;
    print "Hello, World!\n";
    % end

To highlight an included file, use the include helper:

    %= highlight Perl => include ''

The highlight function adds both pre and code tags.

    <p>This example Perl code prints the string "Hello, World" to the screen:</p>
    %= highlight Perl => 'print "Hello, World\n"'

We can override the style we want by passing in a -style option:

    %= highlight -style => 'solarized-dark', Perl => begin
    print "Hello, World!\n";
    % end


Register this plugin with the site. Called automatically.


All of the syntax types supported by the Syntax::Highlight::Engine::Kate Perl module are supported by this module:

    .desktop                ferite                  PHP/PHP
    4GL                     Fortran                 PicAsm
    4GL-PER                 FreeBASIC               Pike
    ABC                     GDL                     PostScript
    Ada                     GLSL                    POV-Ray
    AHDL                    GNU Assembler           progress
    Alerts                  GNU Gettext             Prolog
    ANSI C89                Haskell                 PureBasic
    Ansys                   HTML                    Python
    Apache Configuration    IDL                     Quake Script
    Asm6502                 ILERPG                  R Script
    ASP                     Inform                  RenderMan RIB
    AVR Assembler           INI Files               REXX
    AWK                     Intel x86 (NASM)        RPM Spec
    BaseTest                Java                    RSI IDL
    BaseTestchild           Javadoc                 Ruby
    Bash                    JavaScript              Sather
    BibTeX                  JavaScript/PHP          Scheme
    C                       JSP                     scilab
    C#                      Kate File Template      SGML
    C++                     KBasic                  Sieve
    Cg                      LaTeX                   SML
    CGiS                    LDIF                    Spice
    ChangeLog               Lex/Flex                SQL
    Cisco                   LilyPond                SQL (MySQL)
    Clipper                 Literate Haskell        SQL (PostgreSQL)
    CMake                   Logtalk                 Stata
    ColdFusion              LPC                     TaskJuggler
    Common Lisp             Lua                     Tcl/Tk
    Component-Pascal        M3U                     TI Basic
    CSS                     MAB-DB                  txt2tags
    CSS/PHP                 Makefile                UnrealScript
    CUE Sheet               Mason                   Velocity
    D                       Matlab                  Verilog
    Debian Changelog        MIPS Assembler          VHDL
    Debian Control          Modula-2                VRML
    de_DE                   Music Publisher         Wikimedia
    Diff                    nl                      WINE Config
    Doxygen                 Objective Caml Configuration
    E Language              Objective-C             xHarbour
    Eiffel                  Octave                  XML
    Email                   Pascal                  xslt
    en_US                   Perl                    yacas
    Euphoria                PHP (HTML)              Yacc/Bison


The default, solarized-light, and solarized-dark styles are taken from the Highlight.js project, and are licensed under the BSD license.



The underlying syntax highlighter powering this plugin