|
Hi everyone,
I have been struggling with the following issue, trying to create an extension (with AsciidoctorJ 1.5.4*) that would emit the equivalent of the following raw asciidoc content: ``` a first paragraph listItem1:: some description listItem2:: other text ``` I ran into a couple of issues: - is this even possible? - I'm trying to use a BlockMacroProcessor. Is this the correct way of doing so? - Retrieving the attributes passed to my macro proved to be difficult, as if I only got the "main" text attribute: ``` mymacro::foobar[attr1=wizz, attr2=bar] ``` yields text => "attr1=wizz, attr2=bar" as the sole attribute. I had to resort to this to achieve what I wanted: ``` [attr1=wizz, attr2=bar] mymacro::foobar[] ``` Is this normal, doc? - I am a bit confused about the "context" and "content_model" values that I can/should use. How can one actually create a ":compound" result? Should I just create a parent (my result) block and simply use that parent as the parent of children blocks? All in all, seems like *Block* Macro Processor is not suited for what I want to do, but what should I use then? * I saw 1.6.0 alpha1 had promissing annotation support, together with better documentation for content_model, etc. Sadly, trying to use it (together with the current maven plugin) resulted in JRuby errors. Is there any combination that is known to work? A lot of questions I know, I hope they make sense :) |
|
Hi Eric,
I fear that this is not possible yet with 1.5.x. AsciidoctorJ 1.6.0 would allow to generate Asciidoc content and parse it in a Processor:
Processor.parseContent(parent,
"listitem1:: some description\n" +
"listitem2:: Another");
I think a BlockMacroProcessor should be exactly what you need. Have you already seen this? https://github.com/asciidoctor/asciidoctorj/blob/asciidoctorj-1.6.0/docs/integrator-guide.adoc#block-macro-processors It should explain a bit better how to write a BlockMacroProcessor. Regarding the parent: You would pass the parent passed to your `process()` method also to the `parseContent()` method. It will then append the parsed content to this node. You're right with the Maven plugin. We changed the API in such a manner that the Maven plugin does not work with 1.6.0 atm. Cheers Robert |
|
Thanks Robert,
so I was on the right track but can't do it yet :( Any idea when a 1.6.x compatible maven plugin will be out the door? Also, my "setting the parent" question was more related to creating ":compound" content (my initial request was to issue a paragraph followed by a list, even though I understand that with the parsing API you describe being available, I wouldn't need that). But if you have an example available (even in ruby I guess), that could be interesting. Wait & see then! |
|
Thank you for this message, I think I can also use it for my "reference-toc" macro.
I must tell that I am still in the process of discovering what the Asciidoctor world is offering. As described in the "Using a pre-release version" section there is a maven repo containing the pre-releases… (reading the docs is always good). Here my pom to test it (without the asciidoctor-maven-plugin):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>asciidoctorj.sandbox</groupId>
<artifactId>asciidoctorj-sandbox</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>asciidoctor.maven</id>
<name>asciidoctor bintray repo</name>
<url>http://dl.bintray.com/asciidoctor/maven</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>1.6.0-alpha.1</version>
</dependency>
</dependencies>
</project>
If I understood you guys correctly, we now need a version of the asciidoctor-maven-plugin (maybe also a pre-release) that is compatible with the 1.6.x version of AsciidoctorJ. |
| Free forum by Nabble | Edit this page |
