asciidoctorj - Accessing source text associated with a node

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

asciidoctorj - Accessing source text associated with a node

Michaël Melchiore

Hello,

I am writing a data extractor from Asciidoctor documents using AsciidoctorJ 2.1.0.

I am able to walk through the document AST using the very convenient document.findBy(...) method.

Some data I am interested in the document are tables with a specific role.
For a subset of those tables, my extraction process is limited to writing their raw content into an output (asciidoc) document.

Ideally, I would like to access the Asciidoctor source code of this table section (and this section alone) and write it unmodified in the output file.
Since the AST mostly exposes converted text in HTML format, I have written a small HTML -> Asciidoc converter based on flexmark-java for a simple subset of the Asciidoctor syntax. The Asciidoc -> HTML -> Asciidoc pipeline is wasteful, but it works.

Here are my questions:

1. Is there a way to access the Asciidoctor source code associated with any node ? Is there a node property I am missing ? Only cells provide this feature with the cell.getText() method call
2. The content of the table in HTML format is empty (table.getContent() returns an empty string. Is this intended ?

Kind regards,

Michaël