asciidoctor-ant: add Java extensions?

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

asciidoctor-ant: add Java extensions?

rockyallen
I would like the Ant task to be able to do things like:

<asciidoc:convert ...>
  <yell fontsize="30"/>
  <ChangeAttributeValuePreprocessor key="fruit" value="apple"/>
</asciidoc:convert>

(example processors are from http://asciidoctor.org/docs/asciidoctorj/, but the intention is that it will work with any user-provided Processor subclasses).
This isn't in the asciidoctor-ant task yet, so before I start hacking:
- Is there an existing way to do what I want?
- Is it of interest to anyone else?
- Has someone else tried it?
- The above approach uses Ant to instantiate the extensions; is there a use case for implementing the other ExtensionRegistry.register methods (class and classnane)?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: asciidoctor-ant: add Java extensions?

abelsromero
rockyallen wrote
- Is there an existing way to do what I want?
- Is it of interest to anyone else?
You can always use the SPI interface (http://asciidoctor.org/docs/asciidoctorj/#extension-spi). This involves adding your extension with the`ExtensionRegistry` file in a jar in the classpath of the ant context.
However, the SPI has some limitations, because it means playing with the classpath and this is not always easy.
If Ant allows to easily set the classpath for a task I don't see this is a major issue. If not, then your proposal can come handy.

rockyallen wrote
- Has someone else tried it?
- The above approach uses Ant to instantiate the extensions; is there a use case for implementing the other ExtensionRegistry.register methods (class and classnane)?
A similar discussion took place arround the maven integration some time ago, and I feel the pros/cons are the same here.
The advantage of defining extensions in maven's POM is to be able to play with them using profiles, other than that, the SPI approach is OK.
In my case, I needed to add some customization to documents only under certain conditions.

Here is the conversation: https://github.com/asciidoctor/asciidoctor-maven-plugin/issues/146.
Let me know if you have any doubt about it.




Reply | Threaded
Open this post in threaded view
|

Re: asciidoctor-ant: add Java extensions?

rockyallen
Thanks, I had missed that discussion. I can sort-of see the reasons for avoiding method 3, but I need to configure the processors, and using Ant instantiation is the only sensible way to do that. Time to hack...