Pygments lexer (optional extra)

koskari.extras.pygments

Optional Pygments integration for Koskari syntax highlighting.

Pygments is imported lazily when KoskariLexer or highlight helpers are used. Importing this subpackage does not require Pygments to be installed.

koskari.extras.pygments.highlight_source(source, lexer=None, formatter=None)

Highlight Koskari source to a formatted string via Pygments

Parameters:
  • source – Koskari source text

  • lexer – optional Pygments lexer instance

  • formatter – optional Pygments formatter instance

Returns:

highlighted output string

Raises:

ImportError – when Pygments is not installed

koskari.extras.pygments.register_sphinx_lexer(app)

Register KoskariLexer with a Sphinx application

Parameters:

app – Sphinx application instance

Raises:

ImportError – when Pygments is not installed