Asciidoc Java
The module asciidoc-java
implements a light Asciidoc syntax parser in plain Java. It aims at making it easier and lighter than using JRuby to embed Asciidoc in any Java based (native or not) application.
Its usage is pretty simple:
-
You get a
Parser
instance to load the model of your document in memory (AST), -
You visit the model as you want (or reusing provided
Visitor<?>
) to render the loadedDocument
.
TIP
|
the |
Here is a basic example:
final var parser = new Parser(); (1)
final var doc = parser.parse(myDocContent, new Parser.ParserContext(ContextResolver.of(Path.of("asciidoc/content")))); (2)
final var renderer = new AsciidoctorLikeHtmlRenderer(); (3)
renderer.visit(doc); (4)
final var html = renderer.result(); (5)
- Create a parser instance, can be a singleton in an application,
- Load the document model, can also be a singleton in an application when the conditions depends on attributes,
- Create a renderer (here a html renderer, optionally you can pass it attributes using the other constructor),
- Visit the document,
- Get back the output of the renderer (html output here).
IMPORTANT
|
the asciidoc syntax is not 100% implemented yet, if you encounter anything you miss, feel free to open an issue or pull request on our bugtracker. |