Events in the Java integration?

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

Events in the Java integration?

vmassol
Hi guys,

I'm trying to use AsciiDoctor to implement support for AsciiDoc in XWiki Rendering (http://rendering.xwiki.org). I'm using version 0.1.4 and I was hoping I coud get Events in there but I cannot find them. The best I could fine was TreeProcessor but it doesn't really work:
* It's called after the AST has been created which is too late for my need since I need a streaming parser that can scale to any input size and thus the full AST shouldn't be stored in memory
* I implement a TreeProcessor and I can get a List<Block> using document.blocks(). However the Block interface only has a lines() method to get the content and it seems to be the raw unparsed content (for ex for an input of "this is *bold*", block.lines() will return that string unparsed).

Maybe I missed something and there's a way to get the different kind of Blocks (Paragraph, Word, Bold, List, etc)?

Thank you!
-Vincent

PS: I got a tweet from Dan that prompted me to try 0.1.4: "@vmassol @dobermai @alexsotob @glaforge Events are coming in 0.1.4 release & more in the one ~ Devoxx. It's use of JRuby is not a negative.". Source: https://twitter.com/mojavelinux/status/376809428650971136
Reply | Threaded
Open this post in threaded view
|

Re: Events in the Java integration?

asotobu
For now there is no events, as Dan suggested we should study to see if we add this support or not. But the good news are two:

The fist one is that Marek has implemented for version 1.5.0 a way to retrieve AsciiDoc document in a structured way: https://github.com/asciidoctor/asciidoctorj/pull/104 

Of course he has implemented for his requirements but of course if you found that something is missing, feel free to implement or of course opening an issue and I will try to implement as soon as possible.

The other good news is that a Block method as you suggested contains few methods, but is is so easy to add new ones, because in fact it is a proxied interface to Block Ruby object  (https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/block.rb) so again feel free to open issues to add support on them.

Alex.
Reply | Threaded
Open this post in threaded view
|

Re: Events in the Java integration?

mojavelinux
Administrator

Great response Alex.

As for the events in Asciidoctor core, the short answer is that I just haven't had time to add them in yet. We definitely want to provide the most sensible hook to customize the processor for built-in blocks.

Currently, the only extension points during parsing are for:

- blocks with a custom style
- custom block macros
- custom inline macros

If you want to help design the extension point / mechanism for built-in blocks (e.g., sidebar, example, open, paragraph, etc), we absolutely welcome your input. You can post here or in the issue tracker.

The only constraint is that we want to ensure we don't slow down parsing in the default setup.

Cheers,

-Dan

On Dec 8, 2013 11:01 AM, "asotobu [via Asciidoctor :: Discussion]" <[hidden email]> wrote:
For now there is no events, as Dan suggested we should study to see if we add this support or not. But the good news are two:

The fist one is that Marek has implemented for version 1.5.0 a way to retrieve AsciiDoc document in a structured way: https://github.com/asciidoctor/asciidoctorj/pull/104 

Of course he has implemented for his requirements but of course if you found that something is missing, feel free to implement or of course opening an issue and I will try to implement as soon as possible.

The other good news is that a Block method as you suggested contains few methods, but is is so easy to add new ones, because in fact it is a proxied interface to Block Ruby object  (https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/block.rb) so again feel free to open issues to add support on them.

Alex.


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