Asciidoctorj: API to create a valid AST from scratch

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

Asciidoctorj: API to create a valid AST from scratch

Jeremie Bresson
Is there a way to create a valid Asciidoctor-AST from scratch in Java?

I have seen some methods in org.asciidoctor.extension.Processor…
What if I am not inside a Macro? It is allowed to instantiate a Processor class in a simple main method? How should I initialize the Asciidoctor engine?

In addition, I need to create a separate document (for the root node). Processor#createDocument() seems to be for inner-document, not to create a root document.

Any idea?

Thank you in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctorj: API to create a valid AST from scratch

mojavelinux
Administrator
Jérémie,

This is a great question and also a great next step for the AsciidoctorJ API. When the block creation methods were created, we definitely had extensions in mind, so they ended up in the extensions package. But now we can see that building the AST isn't limited to extensions. Asciidoctor.js ended up following a similar path with the same revelation.

I don't think these methods need to be coupled with the Processor. There's no need to talk about extensions when creating the AST as these are separate concerns. So we need to sort out how to promote these methods into the AST package so that they can be used when working directly with the AST from anywhere.

In trying to build an AST from scratch, we may discover that we need some help from core. Let's cross that bridge when we come to it. To start, can you file an issue to graduate the AST builder methods to the AST package and decouple them from the extension processor?

Keep in mind one thing you won't be able to do is create inline nodes since technnically, inline nodes are never enlisted in the AST. That's an issue we first need to address in core.

Cheers,

-Dan

On Tue, Nov 21, 2017 at 7:52 AM Jeremie Bresson [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Is there a way to create a valid Asciidoctor-AST from scratch in Java?

I have seen some methods in org.asciidoctor.extension.Processor…
What if I am not inside a Macro? It is allowed to instantiate a Processor class in a simple main method? How should I initialize the Asciidoctor engine?

In addition, I need to create a separate document (for the root node). Processor#createDocument() seems to be for inner-document, not to create a root document.

Any idea?

Thank you in advance.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctorj-API-to-create-a-valid-AST-from-scratch-tp6031.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux