Access to the parser in Asciidoctorjs

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

Access to the parser in Asciidoctorjs

geowarin
Hi everyone,

I am trying to lint text in asciidoctor documents.
Being able to access the tokens generated by the parser would help me a great deal with it.
From there it would  possible to skip code blocks or to be sure to run the linter on text nodes only.

If someone could point me the way to do it in Ruby, maybe I can figure out a way to to it with asciidoctorjs (I'm working in node).

Thanks in advance!

PS: marked gives access to its parser, which is pretty awesome!
Reply | Threaded
Open this post in threaded view
|

Re: Access to the parser in Asciidoctorjs

mojavelinux
Administrator
Asciidoctor does not provide low-level access to tokens. But there are various ways to interact with the AST that it does produce to accomplish your goal.

The main entry point is the document and from there the list of blocks. See:


That's a deep as it goes at the moment since the inline parsing is handled in a streaming fashion. That's why we have issue https://github.com/asciidoctor/asciidoctor/issues/61.

In order to do all this in Asciidoctor.js, I recommend writing it in Ruby and compiling it to JavaScript using Opal. It's possible to access the AST from JavaScript, but the API is somewhat awkward. Still, it's workable once you get used to it.

I recommend studying the chrome extension {1} and docgist {2} to see Asciidoctor.js in action.

-Dan



On Tue, Feb 23, 2016 at 8:26 AM, geowarin [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi everyone,

I am trying to lint text in asciidoctor documents.
Being able to access the tokens generated by the parser would help me a great deal with it.
From there it would  possible to skip code blocks or to be sure to run the linter on text nodes only.

If someone could point me the way to do it in Ruby, maybe I can figure out a way to to it with asciidoctorjs (I'm working in node).

Thanks in advance!

PS: marked gives access to its parser, which is pretty awesome!


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Access-to-the-parser-in-Asciidoctorjs-tp4383.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Access to the parser in Asciidoctorjs

mojavelinux
Administrator
In reply to this post by geowarin
You might also want to study the JavaScript parts of AsciidocFX.


-Dan

On Tue, Feb 23, 2016 at 6:59 PM, Dan Allen <[hidden email]> wrote:
Asciidoctor does not provide low-level access to tokens. But there are various ways to interact with the AST that it does produce to accomplish your goal.

The main entry point is the document and from there the list of blocks. See:


That's a deep as it goes at the moment since the inline parsing is handled in a streaming fashion. That's why we have issue https://github.com/asciidoctor/asciidoctor/issues/61.

In order to do all this in Asciidoctor.js, I recommend writing it in Ruby and compiling it to JavaScript using Opal. It's possible to access the AST from JavaScript, but the API is somewhat awkward. Still, it's workable once you get used to it.

I recommend studying the chrome extension {1} and docgist {2} to see Asciidoctor.js in action.

-Dan



On Tue, Feb 23, 2016 at 8:26 AM, geowarin [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi everyone,

I am trying to lint text in asciidoctor documents.
Being able to access the tokens generated by the parser would help me a great deal with it.
From there it would  possible to skip code blocks or to be sure to run the linter on text nodes only.

If someone could point me the way to do it in Ruby, maybe I can figure out a way to to it with asciidoctorjs (I'm working in node).

Thanks in advance!

PS: marked gives access to its parser, which is pretty awesome!


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Access-to-the-parser-in-Asciidoctorjs-tp4383.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Access to the parser in Asciidoctorjs

geowarin
Thank you for your time, Dan.
I will have a look at the resources you provided this weekend and I'll keep you posted.