Interface SyntaxHighlighterAdapter
- All Known Subinterfaces:
Highlighter
public interface SyntaxHighlighterAdapter
This interface has to be implemented by all syntax highlighter adapters, regardless if they
update the resulting HTML document to highlight sources on the client or on the server.
Depending on how the syntax highlighter works in detail one or more of these interfaces should be implemented as well:
Formatter- If the highlighter requires certain classes on the
<pre><code></code></pre>elements that enclose the source text. StylesheetWriter- If the highlighter can write stylesheets to external files in case the document
is rendered with the attributes
:linkcssand:copycss. Highlighter- If the highlighter actually highlights the source text while rendering the asciidoc document to html.
Logging- If the highlighter wants to log to the common Asciidoctor logger.
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:
- name
- A
Stringcontaining the name of the highlighter. - backend
- A
Stringcontaining the backend used for rendering, e.g."html5". - options
- A
Map<String, Object>that contains options for rendering. One key that is always present isdocumentthat contains the currentDocumentthat 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!
-
Method Summary
Modifier and TypeMethodDescriptiongetDocinfo(LocationType location, Document document, Map<String, Object> options) booleanhasDocInfo(LocationType location)
-
Method Details
-
hasDocInfo
-
getDocinfo
-