public interface SyntaxHighlighterAdapter
Depending on how the syntax highlighter works in detail one or more of these interfaces should be implemented as well:
Formatter
<pre><code></code></pre>
elements that enclose the source text.StylesheetWriter
:linkcss
and :copycss
.Highlighter
Logging
SyntaxHighlighterAdapters have to be registered as classes at the
SyntaxHighlighterRegistry
:
Asciidoctor asciidoctor;
asciidoctor.syntaxHighlighterRegistry().register(MySyntaxHighligher.class, "mysyntaxhighighter");
asciidoctor.convert(doc,
OptionsBuilder.options()
.attributes(AttributesBuilder.attributes()
.sourceHighlighter("mysyntaxhighlighter")));
A SyntaxHighlighterAdapter is expected to have a constructor with 3 parameters:
String
containing the name of the highlighter.String
containing the backend used for rendering, e.g. "html5"
.Map<String, Object>
that contains options for rendering.
One key that is always present is document
that contains the current
Document
that is rendered.String
parameters, then this will be used to construct an instance.
This includes using the default constructor if the class defines no constructor at all.
The lifecycle of a SyntaxHighlighter is that one instance is created for every document that is converted.
This API is experimental and might change in an incompatible way in a minor version update!
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDocinfo(LocationType location,
Document document,
java.util.Map<java.lang.String,java.lang.Object> options) |
boolean |
hasDocInfo(LocationType location) |
boolean hasDocInfo(LocationType location)
java.lang.String getDocinfo(LocationType location, Document document, java.util.Map<java.lang.String,java.lang.Object> options)