Part 4

Macros

Ravi Rajani

asciidoctor-html includes some convenient macros in addition to those made available by Asciidoctor.

cref

The cref inline macro allows you to cross reference blocks or anchors in other pages. Reference text gets properly resolved if unspecified.

Table 4.1Example uses of the cref macro
Source Generated Link
cref:index[] Welcome
cref:lists[] Part 2
cref:lists[Ordered Lists] Ordered Lists
cref:lists#sec-pseudocode[] Section 2.4
cref:getting-started#sec-latex[] LaTeX
cref:numbered-blocks#tbl-reference[Reference Table] Reference Table
cref:numbered-blocks#lem-monotone-likelihood[] Lemma 3.2
cref:tests[] Appendix

subnav

The subnav block macro displays a chapter-level navigation menu.

Example uses of the subnav macro

[.mb-4] ①
subnav::[]
  1. mb-4 is provided by Bootstrap to control spacing.

.Contents of cref:numbered-blocks[]
subnav::numbered-blocks[border=1]

footnote

The footnote macro is included in Asciidoctor. However, instead of creating a link to a footnote at the bottom of the page, asciidoctor-html shows the footnote in a popover1, unless presentation or print mode is active, in which case the footnotes in a section are displayed at the bottom of the page.

Use the {parskip} variable to force an appropriate vertical space inside a footnote. Insert the variable directly following the preceding text (with no spaces). This variable can also be useful inside list items.

1
Syntax: footnote:[$content]
Content can include LaTeX such as \[x + 1 = 2 \Rightarrow x = 1\]

bi

You can insert any icon from Bootstrap Icons with the bi macro.

Table 4.2Example uses of the bi macro
Source Generated Icon
bi:arrow-through-heart[]
bi:bicycle[130%]
bi:balloon-fill[100%,magenta]

text

Bootstrap’s semantic inline text elements are supported via the text macro.

These types of markup are built in to the AsciiDoc language and don’t require the text macro.

Table 4.3Example uses of the text macro
Source Generated Text
text:del[deleted text] deleted text
text:strike[no longer accurate] no longer accurate
text:ins[an addition] an addition
text:underline[underlined text] underlined text
text:small[fine print] fine print
text:sc[SmallCaps] SmallCaps
text:muted[faint text] faint text
text:danger[a warning] a warning
text:abbr[attr,title=attribute] attr
text:abbr[HTML,title=HyperText Markup Language,role=initialism] HTML
text:kbd[Ctrl + A] Ctrl + A