Awesome Asciidoctor: Auto Number Callouts

Posted by mariocup on
URL: https://discuss.asciidoctor.org/Awesome-Asciidoctor-Auto-Number-Callouts-tp7488.html

In Asciidoctor it is possible to auto number callouts (see blog post https://mrhaki.blogspot.com). This information should be integrated in the Asciidoctor user manual.

= Callout sample
:source-highlighter: prettify
:icons: font
 
[source,groovy]
----
package com.mrhaki.adoc
 
class Sample {
    String username // <.>
 
    String toString() {
        "${username?.toUpperCase() ?: 'not-defined'}" // <.>
    }
}
----
<.> Simple property definition where Groovy will generate the `setUsername` and `getUsername` methods.
<.> Return username in upper case if set, otherwise return `not-defined`.
When we convert this markup to HTML we get the following result:

This makes it very easy to add new callouts without having to change all numbers we first typed by hand.