AsciiDoc Mastery Reference
A progressive learning guide from everyday patterns to advanced techniques. Organized by frequency of use: start with what you’ll use daily, advance to features that unlock powerful documentation capabilities.
|
This reference assumes you’re writing for Antora-based documentation sites. Some features behave differently in standalone AsciiDoc processing. |
Level 1: Daily Essentials
These patterns cover 80% of documentation work. Master these first.
Document Header
Every .adoc file starts with a header:
= Page Title
:description: SEO description shown in search results
:navtitle: Short Nav Title
:icons: font
| Attribute | Purpose |
|---|---|
|
Meta description for SEO and link previews |
|
Shorter title for navigation sidebar |
|
Enable FontAwesome icons in admonitions |
In Antora, do NOT add :toc: attributes. The UI provides the table of contents globally.
|
Headings
= Document Title (Level 0 - only one per doc)
== Section (Level 1)
=== Subsection (Level 2)
==== Sub-subsection (Level 3)
===== Minor heading (Level 4)
-
Use sentence case: "Getting started" not "Getting Started"
-
Keep hierarchy logical—don’t skip levels
-
Level 1 (
==) is your main content structure
Paragraphs
Just write text. Blank lines separate paragraphs:
First paragraph with some content.
Second paragraph starts after the blank line.
This line continues the second paragraph (no blank line).
Text Formatting
| Style | Syntax | Result |
|---|---|---|
Bold |
|
bold text |
Italic |
|
italic text |
Monospace |
|
|
Bold + Italic |
|
both |
Highlight |
`#highlighted# ` |
highlighted |
Subscript |
|
H2O |
Superscript |
|
x2 |
Links
https://example.com[Click here] (1)
https://example.com[External link^] (2)
link:downloads/file.pdf[Download PDF] (3)
mailto:user@example.com[Email us] (4)
| 1 | Basic external link |
| 2 | Opens in new tab (^ suffix) |
| 3 | Relative path (not URL) requires link: prefix |
| 4 | Email link |
Lists
* Item one
* Item two
** Nested item
*** Deeper nested
* Back to top level
. First step
. Second step
.. Sub-step a
.. Sub-step b
. Third step
* [x] Completed task
* [ ] Pending task
* [*] Also completed (alternate syntax)
Renders as:
-
Completed task
-
Pending task
-
Also completed
Term 1:: Definition for term 1
Term 2:: Definition for term 2
Nested term::: Nested definition
Code Blocks
[source,bash]
----
echo "Hello World"
systemctl restart nginx
----
.Install dependencies
[source,bash]
----
sudo apt update && sudo apt install -y nginx
----
Run `systemctl status nginx` to check the service.
Admonitions
Five built-in types:
NOTE: Supplementary information.
TIP: Helpful suggestion.
IMPORTANT: Key information the reader must know.
WARNING: Potential issues to be aware of.
CAUTION: Actions that could cause harm or data loss.
Renders as:
| Supplementary information. |
| Helpful suggestion. |
| Key information the reader must know. |
| Potential issues to be aware of. |
| Actions that could cause harm or data loss. |
Level 2: Intermediate Patterns
Features you’ll use weekly. These improve readability and maintainability.
Attributes (Variables)
The foundation of DRY documentation:
:project-name: Domus Digitalis
:version: 2026
:server-ip: 10.50.1.60
Welcome to {project-name} version {version}.
Connect to {server-ip} for administration.
| Location | Scope | Use Case |
|---|---|---|
Document header |
Entire document |
Page-specific values |
|
Entire component |
Shared infrastructure values |
CLI/API |
Build-wide |
Environment-specific overrides |
Code Blocks with Callouts
[source,bash]
----
curl -X POST \
-H "Authorization: Bearer $TOKEN" \ (1)
-H "Content-Type: application/json" \
-d '{"key": "value"}' \ (2)
https://api.example.com/endpoint (3)
----
<1> Authentication header with bearer token
<2> JSON payload
<3> API endpoint URL
Renders as:
curl -X POST \
-H "Authorization: Bearer $TOKEN" \ (1)
-H "Content-Type: application/json" \
-d '{"key": "value"}' \ (2)
https://api.example.com/endpoint (3)
| 1 | Authentication header with bearer token |
| 2 | JSON payload |
| 3 | API endpoint URL |
Block Admonitions
For admonitions with complex content:
[WARNING]
====
This operation is destructive:
* All data will be erased
* Backups will not be created automatically
* This cannot be undone
[source,bash]
----
rm -rf /data/*
----
====
Renders as:
|
This operation is destructive:
|
Collapsible Blocks
.Click to see the full configuration
[%collapsible]
====
[source,yaml]
----
server:
port: 8080
ssl:
enabled: true
keystore: /etc/ssl/keystore.jks
----
====
Renders as:
Click to see the full configuration
server:
port: 8080
ssl:
enabled: true
keystore: /etc/ssl/keystore.jks
Cross-References
[[my-anchor]]
== Section Title
Later: see <<my-anchor>> or <<my-anchor,custom text>>.
xref:other-page.adoc[Other Page]
xref:folder/nested.adoc[Nested Page]
\xref:page.adoc#section-id[Specific Section]
xref:infra-ops::runbooks/vault.adoc[Vault Runbook]
xref:netapi:ROOT:cli/ise.adoc[ISE CLI Reference]
Includes (Antora)
include::partial$security-warning.adoc[]
[source,bash]
----
include::example$scripts/backup.sh[]
----
include::example$config.yaml[lines=10..25]
| Prefix | Directory |
|---|---|
|
|
|
|
|
|
|
|
Table Column Formatting
[cols="2,1,1"] (1)
[cols="<1,^2,>1"] (2)
[cols="1a,2"] (3)
[cols="1h,2"] (4)
| 1 | Proportional widths (2:1:1) |
| 2 | Alignment: < left, ^ center, > right |
| 3 | a = AsciiDoc content in cells |
| 4 | h = header style column |
[cols="1,2",options="header"]
|===
|Name |Description
|Item 1 |First item description
|Item 2 |Second item description
|===
Sidebar Blocks
****
This is a sidebar block.
Use for supplementary content, tips, or asides that shouldn't interrupt the main flow.
****
Renders as:
Level 3: Advanced Features
Features that unlock powerful documentation patterns. Use when basic features aren’t enough.
Attribute References in Code Blocks
By default, {attributes} don’t resolve in code blocks. Enable with subs:
[source,bash,subs="attributes+"]
----
export VAULT_ADDR="{vault-addr}"
curl -s {vault-addr}/v1/sys/health
----
| Value | Effect |
|---|---|
|
Add attribute substitution |
|
Add quote processing ( |
|
Replace defaults with these only |
|
Disable all substitutions |
Conditional Content
TIP: This is the development version. Things may change.
This appears in HTML5 OR PDF output.
ifeval: Expression Evaluation
For comparisons beyond simple presence checks:
This content is HTML5-specific.
| Operator | Meaning |
|---|---|
|
Equal / Not equal |
|
Less than / Less or equal |
|
Greater than / Greater or equal |
Both sides must be same type. Quote strings: "{attr}" == "value"
|
Include with Tags
Mark regions in source files:
#!/bin/bash
# tag::setup[]
export VAULT_ADDR="https://vault.example.com:8200"
# end::setup[]
# tag::main[]
vault kv get secret/data
# end::main[]
# tag::cleanup[]
unset VAULT_TOKEN
# end::cleanup[]
Include specific tags:
.Setup phase
[source,bash]
----
include::example$vault-script.sh[tag=setup]
----
.Main operation
[source,bash]
----
include::example$vault-script.sh[tag=main]
----
include::example$script.sh[tags="setup;main"]
include::example$script.sh[tags="!cleanup"]
Include with Level Offset
Adjust heading levels of included content:
= Main Document
include::chapter.adoc[leveloffset=+1]
The = Heading in chapter.adoc becomes == Heading in the output.
Counter Attributes
Auto-incrementing counters for numbering:
{counter:step}. Configure the server (1)
{counter:step}. Install dependencies (2)
{counter:step}. Start the service (3)
| 1 | Outputs: 1. Configure the server |
| 2 | Outputs: 2. Install dependencies |
| 3 | Outputs: 3. Start the service |
Appendix {counter:appendix:A}: Introduction
Appendix {counter:appendix}: Configuration
Appendix {counter:appendix}: Troubleshooting
Step {counter:num}: Do something
Reminder: We're on step {counter2:num} (1)
Step {counter:num}: Do next thing
| 1 | counter2 displays current value without incrementing |
Intrinsic Attributes
Built-in attributes populated automatically:
| Attribute | Value | Example |
|---|---|---|
|
Filename (no extension) |
|
|
Full file path |
|
|
Directory path |
|
|
Current date |
|
|
Current time |
|
|
Date and time |
|
|
Processor version |
|
|
Output format |
|
|
Output extension |
|
Document: {docname}
Generated: {localdate} at {localtime}
Character Replacement Attributes
Special characters as attributes:
| Attribute | Character | Use Case |
|---|---|---|
|
Non-breaking space |
Keep together: |
|
Zero-width space |
Allow breaks: |
|
Nothing |
Empty table cells |
|
Space |
Force space in macros |
|
Word joiner |
Prevent breaks |
| Attribute | Character |
|---|---|
|
" " |
|
' ' |
|
° |
|
+ |
|
' |
| Attribute | Escapes |
|---|---|
|
|
|
|
|
|
|
|
Advanced Tables
[cols="1,2a"]
|===
|Feature |Example
|Nested list
|
* Item one
* Item two
* Item three
|Code block
|
[source,bash]
echo "hello"
|===
|===
|A |B |C
3+|This cell spans all 3 columns
.2+|Row span
|Normal
|Normal
|Also normal
|Also normal
|===
| Syntax | Effect |
|---|---|
|
Span 3 columns |
|
Span 2 rows |
|
Span 2 columns AND 3 rows |
[%header,format=csv]
|===
Name,IP,Role
vault-01,10.50.1.60,Primary
vault-02,10.50.1.61,Standby
|===
[cols="1,2"]
|===
|Outer
a|
[cols="1,1"]
!===
!Inner !Table
!A !B
!===
|===
Note: Nested tables use !=== instead of |===.
Text Spans and Roles
Apply CSS classes to inline text:
[.underline]#Underlined text#
[.line-through]#Strikethrough text#
[.big]#Larger text#
[.small]#Smaller text#
[.underline.line-through]#Combined styles#
| Role | Effect |
|---|---|
|
Underline |
|
Overline |
|
Strikethrough |
|
Prevent word breaks |
|
Prevent line wrap |
|
Preserve whitespace |
[.lead]
This paragraph gets "lead" styling—larger intro text.
[.text-center]
====
This block is centered.
====
Pass Macro (Passthrough)
Control substitutions on inline content:
pass:[<b>Raw HTML</b>] (1)
pass:q[*bold* inside passthrough] (2)
pass:a[Server: {server-ip}] (3)
pass:c,a[<{email}>] (4)
| 1 | No substitutions—raw to output |
| 2 | q = quotes (bold/italic work) |
| 3 | a = attributes resolve |
| 4 | Multiple: c (special chars) + a (attributes) |
| Code | Name | Effect |
|---|---|---|
|
specialchars |
Escape |
|
quotes |
Process |
|
attributes |
Resolve |
|
replacements |
|
|
macros |
Process |
|
post_replacements |
Line break processing |
Level 4: Expert Techniques
Advanced patterns for complex documentation systems.
Substitution Order
AsciiDoc applies substitutions in this order:
-
Special characters (
<,>,&) -
Quotes (
bold,italic) -
Attributes (
{name}) -
Replacements (
->→→) -
Macros (
image::,xref:) -
Post-replacements (line breaks)
Understanding this helps debug why content doesn’t render as expected.
Attribute Precedence
When same attribute is defined multiple places:
CLI/API (hard-set) > Document > CLI/API (soft-set)
asciidoctor -a version=1.0@ (1)
asciidoctor -a version=1.0 (2)
| 1 | @ suffix = document can override |
| 2 | No suffix = locked, document cannot override |
Block Nesting
When nesting same-type blocks, vary delimiter length:
.Outer example
======
Content in outer.
.Inner example
====
Content in inner.
====
Back to outer.
======
Open Block Flexibility
Open blocks (--) can become any type with a style attribute:
[source,python]
--
print("Acts like source block")
--
[quote]
--
Acts like quote block.
--
[sidebar]
--
Acts like sidebar block.
--
STEM (Math Notation)
Enable in header:
:stem: (1)
:stem: latexmath (2)
| 1 | Default to AsciiMath |
| 2 | Default to LaTeX |
The quadratic formula: stem:[x = (-b pm sqrt(b^2 - 4ac)) / (2a)]
Using LaTeX: latexmath:[E = mc^2]
[stem]
++++
sum_(i=1)^n i = (n(n+1))/2
++++
| AsciiMath | LaTeX |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Footnotes
Important statement.footnote:[Supporting reference here.]
Reusable footnote.footnote:fn1[This footnote can be referenced again.]
Later reference.footnote:fn1[]
Index Terms
For generated indexes (PDF, EPUB):
((Vault)) is used for secrets management. (1)
(((PKI, certificates, TLS))) (2)
This section covers TLS certificates.
A visible term indexterm:[indexing] (3)
| 1 | Visible term added to index |
| 2 | Hidden triple-level index entry |
| 3 | indexterm macro for hidden entries |
Practical Patterns
Real-world patterns that combine multiple features.
DRY Infrastructure Documentation
Define in antora.yml:
asciidoc:
attributes:
vault-addr: https://vault-01.inside.domusdigitalis.dev:8200
vault-port: 8200
homedc-ip: 10.50.1.50
Use everywhere:
[source,bash,subs="attributes+"]
----
export VAULT_ADDR="{vault-addr}"
kinit user@DOMAIN -S host/{homedc-ip}
----
Platform-Specific Instructions
[tabs]
====
Linux::
+
[source,bash]
----
sudo apt install vault
----
macOS::
+
[source,bash]
----
brew install vault
----
Windows::
+
[source,powershell]
----
choco install vault
----
====
| Tabs require Antora UI support or Asciidoctor Tabs extension. |
Reusable Warning Blocks
Create partials/production-warning.adoc:
[CAUTION]
====
*Production Environment*
This operation affects live systems:
* Ensure maintenance window is scheduled
* Verify backup completed successfully
* Have rollback plan ready
====
Include where needed:
include::partial$production-warning.adoc[]
Auto-Generated Timestamps
.Document Information
[cols="1,2"]
|===
|Generated |{localdatetime}
|Source |{docname}{docfilesuffix}
|Processor |Asciidoctor {asciidoctor-version}
|===
Common Mistakes and Fixes
| Mistake | Fix |
|---|---|
|
Remove it—Antora UI provides TOC |
|
Add |
|
Use |
|
Use |
Hardcoded IPs in docs |
Define in |
Missing blank line before list |
AsciiDoc needs blank line to start list context |
|
Must be |
Forward attribute reference |
Attributes must be defined before use |
Contributing to AsciiDoc Community
Welcome to the community! Here’s how to contribute:
Where to Contribute
| Project | Repository |
|---|---|
AsciiDoc Language |
|
Asciidoctor (Ruby) |
|
Asciidoctor.js |
|
Antora |
|
Asciidoctor PDF |
|
Asciidoctor Diagram |
Contribution Ideas
-
Fix typos and unclear explanations
-
Add examples for undocumented features
-
Translate documentation
-
Write tutorials and guides
-
Fix bugs (check issue trackers)
-
Implement feature requests
-
Improve error messages
-
Add tests for edge cases
-
Answer questions on GitHub Discussions
-
Help triage issues
-
Review pull requests
-
Share your AsciiDoc projects
Quick Reference Card
Most Common Patterns
= Title <-- Document title
== Section <-- Level 1 heading
*bold* _italic_ `code` <-- Inline formatting
https://url[text] <-- Link
image::file.png[alt] <-- Block image
\xref:page.adoc[text] <-- Cross-reference
\{attribute-name} <-- Attribute reference
\include::partial$file.adoc[] <-- Include partial
[source,lang] <-- Code block start
---- <-- Code block delimiter
NOTE: text <-- Admonition
Delimiter Reference
| Delimiter | Block Type | Use |
|---|---|---|
|
Listing/Source |
Code blocks |
|
Literal |
Preformatted text |
|
Example |
Examples, collapsibles |
|
Sidebar |
Supplementary content |
|
Quote/Verse |
Quotations |
Passthrough |
Raw HTML |
|
|
Open |
Flexible (any style) |
|
Comment |
Hidden content |
|
Table |
Tabular data |