Skip to content

Latest commit

 

History

History
75 lines (46 loc) · 2.32 KB

TUTORIAL-5min.adoc

File metadata and controls

75 lines (46 loc) · 2.32 KB

Starting with Jamal in 5 minutes

The easiest way is to use Jamal is the IntelliJ IDEA Asciidoctor plugin with the Jamal extension.

Installing the plugin

The installation of the Jamal extension for the IntelliJ Asciidoctor plugin is a 2-minute process. The detailed steps are described in the README of the plugin.

Starting up

After the configuration you just need to start IntelliJ and create a new file named README.adoc.jam in the project. The plugin and the preprocessor will automatically start.

The content of the file can be the following:

= README.adoc.jam

//{%@rot13 QB ABG RQVG GUVF SVYR; GUVF VF TRARENGRQ SEBZ FNZCYR_ERNQZR.nqbp.wnz%}

{%@snip:xml pom=../pom.xml%}\
{%#define VERSION={%pom /project/version/text()%}%}\

How to use Jamal in five minutes.
This is a sample readme of the version `{%VERSION%}`.

This file contains a comment line. It is encrypted in the source code and decrypted in the generated file. It uses the rot13 macro to encode the text. The encoded text is:

//DO NOT EDIT THIS FILE; THIS IS GENERATED FROM SAMPLE_README.adoc.jam

This is a neat trick to have this text in the generated file without having the same in the source. When you read the source, it is a gibberish. When you read in the generated file, it is a rclear warning.

It is also a simple demonstration of a simple macro.

The next thing is a snippet collection. In this case we collect an XML snippet into the snippet named pom. The next line uses the define macro to define VERSION. The content of the macro is the version from the pom.xml file.

The last line shows how to use this defined macro.

The result, processed by Jamal finally is:

= README.adoc.jam

//DO NOT EDIT THIS FILE; THIS IS GENERATED FROM SAMPLE_README.adoc.jam


How to use Jamal in five minutes.
This is a sample readme of the version `2.8.3-SNAPSHOT`.

With this, you started using Jamal in five minutes. Here we used three macros, but there are around 200 different macros in the library. You can also create your own macros.

For further information, read the documents listed in the README.