HUGO
Menu
GitHub 90198 stars Mastodon

transform.CanHighlight

Reports whether the given language is supported for syntax highlighting.
Syntax
transform.CanHighlight LANGUAGE
Returns
bool

Usage

The transform.CanHighlight function reports whether the given language is supported for syntax highlighting. The LANGUAGE argument is case-insensitive. See the list of supported languages.

If the syntax highlighter does not support a language, it renders the code without highlighting. Use this function before calling the transform.Highlight or transform.HighlightCodeBlock function to decide how to handle an unsupported language, such as by substituting a different language.

Examples

{{ transform.CanHighlight "go" }} → true
{{ transform.CanHighlight "klingon" }} → false