HighlightCode Class
Applies syntax highlighting to code blocks.
Namespace
Statiq.Highlight
Interfaces
Base Types
graph BT Type-->Base0["Module"] click Base0 "/api/Statiq.Common/Module" Base0-->Base1["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type["HighlightCode"] class Type type-node

Syntax

public class HighlightCode : Module, IModule

Examples

Pipelines.Add("Highlight",
    ReadFiles("*.html"),
    Highlight(),
    WriteFiles(".html")
);

Remarks

This module finds all <pre> <code> blocks and applies HighlightJs's syntax highlighting.

Note that because this module parses the document content as standards-compliant HTML and outputs the formatted post-parsed DOM, you should only place this module after all other template processing has been performed.

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module.
Inherited from Module
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
WithAutoHighlightUnspecifiedLanguage(bool) HighlightCode
Sets whether auto highlighting is performed when there is no language specified on the code block.
WithCodeQuerySelector(string) HighlightCode
Sets the query selector to use to find code blocks.
WithCustomHighlightJs(string) HighlightCode
Sets the file path to a custom highlight.js file. If not set the embeded version will be used.
WithMissingLanguageWarning(bool) HighlightCode
Sets whether a warning should be raised if a missing language is detected in a code block.

Extension Methods