Catalog / Asciidoctor Cheat Sheet

Asciidoctor Cheat Sheet

A quick reference guide to AsciiDoc syntax, covering fundamental elements for document creation and formatting with Asciidoctor.

Basic Syntax

Document Structure

= Document Title
:Author: Your Name
:Date: 2024-01-01

Document body starts here.

= Article Title
John Smith [email protected]
v1.0, 2024-01-01
:doctype: article

[preamble]
A short introduction or overview of the document’s content.

Headings

= Level 1 Heading
== Level 2 Heading
=== Level 3 Heading
==== Level 4 Heading
===== Level 5 Heading

Each = corresponds to a heading level. Asciidoctor supports up to 6 heading levels.

Paragraphs & Line Breaks

Paragraphs

Separate paragraphs with a blank line.

Line Breaks

End a line with + to force a line break.

Example:
This is line one. +
This is line two.

Text Formatting

Basic Styles

Emphasis

For italics or emphasis.

Strong

For bold or strong emphasis.

Monospaced

For code or monospaced text.

Marked

For highlighted text.

Quotes & Citations

[quote, Attribution, Source]


Block quote text here.


[cite, id]
<>

Use [cite, id] to reference a bibliography entry.

Superscript and Subscript

Superscript

Renders text as superscript.

Subscript

Renders text as subscript.

Lists and Tables

Unordered Lists

  • Item 1
  • Item 2
    ** Sub-item 1
    ** Sub-item 2
  • Item 3

Use * for unordered list items. Use multiple * for nested items.

Ordered Lists

. Item 1
.. Sub-item 1
.. Sub-item 2
. Item 2
. Item 3

Use . for ordered list items. Use multiple . for nested items.

Description Lists

Term:: Description of the term.
Term 2:: Description of the second term.

Use Term:: Description for description lists.

Tables

[cols=“1,1,2”]
|===
| Header 1 | Header 2 | Header 3
| Cell 1 | Cell 2 | Cell 3
| Cell 4 | Cell 5 | Cell 6
|===

Define columns with [cols="..."]. Use | to separate cells. |=== marks the beginning and end of the table.

Links and Includes

Links

Use https://... for automatic links. Use link:URL[Text] for custom link text.

Images

image::image.png[alt text]
Inline image.

image::images/diagram.png[Diagram, 300, 200]
Image with width and height.

Use image::path[alt text, width, height] to embed images.

Includes

include::chapter1.adoc[]
Includes the content of chapter1.adoc.

include::attributes.adoc[leveloffset=+1]
Include and increase heading levels by 1.

Use include::path[] to include other AsciiDoc files.

Code Blocks

[source, ruby]

puts “Hello, world!”

[listing]

This is a listing block.

Use [source, language] for code blocks with syntax highlighting. Use [listing] for plain text blocks.