Highlight Wyam.Highlight

Adds code highlighting CSS styles.
This module pre-generates highlight.js (https://highlightjs.org) code highlighting styles. Note that a highlight.js stylesheet must still be referenced for the styles to render in different colors.


This module exists in the Wyam.Highlight package which is not part of the core distribution. Add the following preprocessor directive to your configuration file to use it:
#n Wyam.Highlight


Example usage:

<?# highlight csharp ?>
public class Foo
  int Bar { get; set; }
<?#/ highlight ?>

Example output:

<code class="language-csharp hljs"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Foo</span>
  <span class="hljs-keyword">int</span> Bar { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }


The following parameters can be used without names in the order below or with names (provided they are named) in any order. When using named parameters, the syntax should be `Name=Value` or `Name="Value"`.

  • Language

    The highlight.js language name to highlight as (for example, "csharp").

  • Element

    An element to wrap the highlighted content in. If omitted, <code> will be used.

  • HighlightJsFile

    Sets the file path to a custom highlight.js file. If not set the embeded version will be used.