An example project that demonstrates how to convert multiple input AsciiDoc documents to HTML5 and PDF using the Asciidoctor Maven plugin.
Convert the AsciiDoc to PDF and HTML5 by invoking the process-resources
goal (configured as the default goal):
$ mvn
Open the files target/generated-docs/example-manual.html and target/generated-docs/example-technical-doc.html in your browser to see the generated HTML file.
By defining multiple execution blocks, you can configure different input documents, output formats or various other configuration parameters.
In the example, we define a first execution block as follows:
<execution>
<id>asciidoc-usermanual-to-pdf</id> (1)
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<sourceDirectory>src/docs/asciidoc/user-manual</sourceDirectory> (2)
<backend>pdf</backend> (3)
<!-- Since 1.5.0-alpha.9, PDF back-end can also use 'rouge' which provides more coverage
for other languages like scala -->
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<pagenums/>
<toc/>
<idprefix/>
<idseparator>-</idseparator>
</attributes>
</configuration>
</execution>
-
Define a unique id for your execution block
-
Define the source directory where the asciidoc source document for the manual is located
-
Select
pdf
as the output format
Note
|
You also need to add a dependency on <dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>1.5.0-alpha.9</version>
</dependency> |
The second execution block defines how to create the technical documentation in HTML:
<execution>
<id>asciidoc-techdocs-to-html</id> (1)
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<sourceDirectory>src/docs/asciidoc/technical-docs</sourceDirectory> (2)
<backend>html5</backend> (3)
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<imagesdir>./images</imagesdir>
<toc>left</toc>
<icons>font</icons>
<sectanchors>true</sectanchors>
<!-- set the idprefix to blank -->
<idprefix/>
<idseparator>-</idseparator>
<docinfo1>true</docinfo1>
</attributes>
</configuration>
</execution>
-
Define a unique id for your execution block. Make sure it is different from the other execution block(s)
-
Define the source directory where the asciidoc source document for the technical docs is located
-
Select
html5
as the output format
You can of course define as many execution blocks as wanted.