To make an image linkable in Asciidoctor when formatted to HTML we must use the link
attribute when we use the image
macro. The value of the link
attribute is the address where the user goes when clicking on the image. We can also specify extra link attributes like window
to specify the target window for the link to open in.
In the following example we use the link
attribute for a block and inline image, with and without an extra window
attribute:
Continue reading →
In a previous post we learned about callouts in Asciidoctor to add explanation to source code. While surfing the Internet I came upon the following blog post by Alex Soto: Auto-numbered Callouts in Asciidoctor. I turns out that since Asciidoctor 1.5.8 we can use a dot (.
) instead of explicit numbers to have automatic increasing numbering for the callouts.
Let’s take our example from the earlier blog post and now use auto numbered callouts:
Continue reading →
If we want to include Asciidoc markup as source language and show the markup without transforming it we can use a listing or literal block. For example we are using Asciidoc markup to write a document about Asciidoctor and want to include some Asciidoc markup examples. If the markup contains sections like a listing or literal block and it is enclosed in a listing or literal block, the tranformation goes wrong. Because the beginning of the included listing or literal block is seen as the ending of the enclosing listing or literal block. Let’s see what goes wrong with an example where we have the following Asciidoc markup:
When we transform this to HTML we get the following output:
Continue reading →
In a previous post we learned how to include parts of a document in the generated output.
The included parts are defined using tags.
The start of a tag is defined in a comment with the format tag::_tagName_[]
and the end has the format end::_tagName_[]
.
Next we must use the tags
attribute for the include
macro followed by the tagName.
If we don’t want to include a tag we must prefix it with an exclamation mark (!
).
Continue reading →
Document attributes in Asciidoctor are very powerful.
We can assign values to a document attributes and reference the attribute name in our document enclosed between curly braces.
Asciidoctor will fill in the value when the document is transformed.
Instead of a plain value we can also use styling markup in the document attribute definition.
We must use the passthrough macro and allow for quote substitution.
In the following example document we define three document attributes: cl-added
, cl-updated
and cl-changed
.
We use the passthrough macro, quotes substation to assign CSS classes:
Continue reading →
Spring REST Docs is a project to document a RESTful API using tests.
The tests are used to invoke real REST calls on the application and to generate Asciidoctor markup snippets.
We can use the generated snippets in an Asciidoctor document with documentation about our API.
We can use Spring REST Docs to document a REST API we create using Micronaut.
First we must change our build file and include the Asciidoctor plugin and add dependencies to Spring REST Docs.
The following example Gradle build file adds the Gradle Asciidoctor plugin, Spring REST Docs dependencies and configures the test
and asciidoctor
tasks.
Spring REST Docs supports three different web clients to invoke the REST API of our application: Spring MockMVC, Spring Webflux WebTestClient and REST Assured.
We use REST Assured 3, because it has little dependencies on other frameworks (like Spring).
Continue reading →
With the Asciidoctor diagram extension we can include diagrams that are written in plain text.
For example PlantUML or Ditaa diagrams.
The extension offers a block processor where we include the diagram definitions in our Asciidoctor document.
But there is also a block macro processor. With the block macro processor we can refer to an external file.
The file is processed and the resulting image is in our output document.
In the following example we see how to use the block macro for a Ditaa diagram:
Continue reading →
When we define a list in Asciidoctor we usually have a list item that is a paragraph.
But if we want to have a block as list item we need to add an extra
element to make sure the block is parsed correctly as list item.
Because a list item starts with a .
or a *
at the beginning of a line and a block also is defined on the beginning of the line, we must add the extra
element.
Together with the list item continuation (+
) we can have a list with blocks.
In the following example we define a numbered list with three listing blocks:
Continue reading →
Normally if we type an URL in Asciidoctor that starts with a scheme Asciidoctor knows about, the URL is turned into a hyperlink.
The following schemes are recognized by Asciidoctor:
Continue reading →
With Asciidoctor markup we can position images in our document.
We can even float images, so text can next to an image, inside only below or about the image.
We can also define multiple images to float, so the images are displayed on the same line next to each other.
Any text that follows these images is also displayed next to the images.
If we want only to have floating images, but the text starting under the images we can place the images inside an open block and assign the block the role float-group
.
In the next example we first define three images that all have roles to float left.
In the second part we group these images using the role float-group
, so the text will not be displayed next to the images, but under the images:
Continue reading →
In a previous post we learned how to use data in CSV and DSV format.
Recently we can also include tab separated values (TSV) in a Asciidoctor table.
We must set the table attribute format
to the value tsv
.
The data can be inside the document, but also defined in an external file which we add with the include
macro.
In the following example markup we have a table with inline tab separated values.
A second table includes an external file with tab delimited values:
Continue reading →
When we write a list in Asciidoctor we can simply create a list item by starting the line with a dot (.
).
To create a another list item we simply start a new line with a dot (.
).
But what if we want to add a list item with multiple paragraphs, or text and a source code block element.
We can use the list item continuation (+
) to indicate to Asciidoctor we want to keep these together for a single list item.
In the following example we have a list in Asciidoctor markup.
The second list item has multiple paragraphs , the third item has an extra admonition block and the fourth item contains a source code block:
Continue reading →