I'm writting a block extension which is basically a rip-off of the Yell example from (https://github.com/asciidoctor/asciidoctorj#block-processor) but I'm not being able to execute it.
The example as-is fails with a ruby exception, and after checking the tests in Asciidoctorj code I see that some additional parameters are passed to the constructor: This works for a simple Asciidoc file with nothing more than the underlying lines, but does not work in a more complex file. The thing is that when I insert this block in a more complex file, the 'process' method of the extension is not executed. I can validate that the extension is correctly registered to 'yell' debugging the constructor, but the 'process' method is simply never used. Also I tried using ':compound' for 'content_model' but nothing changed. ¿Am I missing something or is it a bug? Right now I'm testing it with a modified 'sample.asciidoc ' from the maven-plugin tests:
|
Administrator
|
Abel, This happens because you are putting yell on a different type of block than what is registered. In the example, it is only registered on a paragraph. Since you've placed it on a listing block, you have to tell Asciidoctor to register the extension for that block context. put("contexts", Arrays.asList(":listing")); Then, it should work. In the future, we need to find a simpler way to define the contexts for which a block extension is registered. I proposed an idea in the following issue: https://github.com/asciidoctor/asciidoctorj/issues/196 Cheers, On Sat, Jan 31, 2015 at 4:37 PM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote: I'm writting a block extension which is basically a rip-off of the Yell example from (https://github.com/asciidoctor/asciidoctorj#block-processor) but I'm not being able to execute it. -- Dan Allen | http://google.com/profiles/dan.j.allen |
Works peftectly, thanks a lot.
Imho, these details should be more documented because currently the documentation is confusing. From the Asciidoctorj and Asciidoctor examples (http://asciidoctor.org/docs/user-manual/#extensions) it seems as is nothing else is necessary, but truth is that you need to set some parameters on the constructors to make them work. I found this issue https://github.com/asciidoctor/asciidoctor-documentation/issues/30 and I inderstand that the asciidoctor part is on-the-work. So, just to ease Java extensions, mind if I open and issue in asciidoctorj to improve the current examples? |
Administrator
|
This is a case when the Ruby and Java environments have very different requirements. In the Ruby side, we use the DSL to configure the blocks, whereas in the Java side its necessary to use the constructor. That's why I like the idea of opening an issue to improve the README for AsciidoctorJ, which currently serves as the "user manual" for that module. Please file the issue when you get a chance. -DanThanks! On Sun, Feb 1, 2015 at 1:44 AM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote: Works peftectly, thanks a lot. -- Dan Allen | http://google.com/profiles/dan.j.allen |
Free forum by Nabble | Edit this page |