Interface Highlighter
-
- All Superinterfaces:
SyntaxHighlighterAdapter
public interface Highlighter extends SyntaxHighlighterAdapter
A Highlighter transforms the actual raw source text. While aSyntaxHighlighterAdapter
alone might only include the necessary stylesheets and scripts to highlight the sources in the browser, aHighlighter
can actually transform the source to static HTML.If a
SyntaxHighlighterAdapter
also implements this interface, the methodhighlight(Block, String, String, Map)
will be called for every source block.This API is experimental and might change in an incompatible way in a minor version update!
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HighlightResult
highlight(Block node, java.lang.String source, java.lang.String lang, java.util.Map<java.lang.String,java.lang.Object> options)
Highlights the source according to the language.-
Methods inherited from interface org.asciidoctor.syntaxhighlighter.SyntaxHighlighterAdapter
getDocinfo, hasDocInfo
-
-
-
-
Method Detail
-
highlight
HighlightResult highlight(Block node, java.lang.String source, java.lang.String lang, java.util.Map<java.lang.String,java.lang.Object> options)
Highlights the source according to the language.- Parameters:
node
- The node of the Asciidoctor AST that contains the source to be highlighted.source
- The full content of the source block as one String.lang
- The language that was associated with the source block, e.g.java
orruby
.options
- A map containing options for conversion:callouts
- A map containing all callouts indexed by line number (1-based) (optional).
That means
((Map)options.get("callouts")).get(1L)
will return the List of callouts in the first line. The value for each callout is a List with 2 elements: The optional comment text before the callout, e.g.//
, and the callout number, e.g"1"
. - css_mode
- The CSS mode as a String,
"class"
or"inline"
- highlight_lines
- A 1-based Array of Integer line numbers to highlight (aka emphasize) (optional).
- number_lines
- A String indicating whether lines should be numbered
(
"table"
or"inline"
) (optional). - start_line_number
- The starting Integer (1-based) line number (optional, default: 1).
- style
- The String style (aka theme) to use for colorizing the code (optional).
- Returns:
- A
HighlightResult
containing the converted HTML as a String and optionally a line offset.
-
-