Asciidoc Cheat Sheet

AsciiDoc is a human-readable document format, semantically equivalent to DocBook XML, but using plain-text mark-up conventions. AsciiDoc documents can be created using any text editor and read 'as-is', or rendered to HTML or any other format supported by a DocBook tool-chain, i.e. PDF, TeX, Unix manpages, e-books, slide presentations, etc Read more in wikipedia


Heading

= h1
== h2
=== h3
==== h4
===== h5

h1

h2

h3

h4

h5


Specising

{nbsp} +
{sp} +
{empty} +
{zwsp} +
{blank} +


Quoted text

I can't believe it, we *won*!

I can’t believe it, we won!


Bold, italic, and monospace formatting syntax

bold *constrained* & **un**constrained

italic _constrained_ & __un__constrained

bold italic *_constrained_* & **__un__**constrained

monospace `constrained` & ``un``constrained

monospace bold `*constrained*` & ``**un**``constrained

monospace italic `_constrained_` & ``__un__``constrained

monospace bold italic `*_constrained_*` & ``**__un__**``constrained

bold constrained & unconstrained

italic constrained & unconstrained

bold italic constrained & unconstrained

monospace constrained & unconstrained

monospace bold constrained & unconstrained

monospace italic constrained & unconstrained

monospace bold italic constrained & unconstrained


Replacements

  1. Copyright > (C) > ©

  2. Registered > (R) > ®

  3. Trademark > (TM) > ™

  4. Em dash > -- > — 

  5. Ellipsis > ... > …​

  6. Single right arrow > -> > →

  7. Double right arrow > => > ⇒

  8. Single left arrow > <- > ←

  9. Double left arrow > <= > ⇐


Wrapped text and hard line breaks

Line breaks preserved using a space followed by the plus sign (+)

Rubies are red, +
Topazes are blue.

Rubies are red,
Topazes are blue.

Line breaks preserved using the hardbreaks option

[%hardbreaks]
Ruby is red.
Java is black.

Ruby is red.
Java is black.


List

  1. Unordered

  2. Ordered

  3. Description


Lists of things

1st Way
* Edgar Allen Poe
* Sheri S. Tepper
* Bill Bryson
  • Edgar Allen Poe

  • Sheri S. Tepper

  • Bill Bryson


2nd Way
- Edgar Allen Poe
- Sheri S. Tepper
- Bill Bryson
  • Edgar Allen Poe

  • Sheri S. Tepper

  • Bill Bryson


3rd Way Nested
* level 1
** level 2
*** level 3
**** level 4
***** level 5
* level 1
  • level 1

    • level 2

      • level 3

        • level 4

          • level 5

  • level 1


Ordering the things

Basic Way
. Protons
. Electrons
. Neutrons
  1. Protons

  2. Electrons

  3. Neutrons


The step will Started from 4
[start=4]
. Step four
. Step five
. Step six
  1. Step four

  2. Step five

  3. Step six


Step can be reversed order
[%reversed]
. Protons
. Electrons
. Neutrons
  1. Protons

  2. Electrons

  3. Neutrons


A nested ordered list
. Step 1
. Step 2
.. Step 2a
.. Step 2b
. Step 3
  1. Step 1

  2. Step 2

    1. Step 2a

    2. Step 2b

  3. Step 3


Description lists

1st Way
CPU:: The brain of the computer.
Hard drive:: Permanent storage for operating system and/or user files.
RAM:: Temporarily stores information the CPU uses during operation.
Keyboard:: Used to enter text or control items on the screen.
Mouse:: Used to point to and select items on your computer screen.
Monitor:: Displays information in visual form using text and graphics.
CPU

The brain of the computer.

Hard drive

Permanent storage for operating system and/or user files.

RAM

Temporarily stores information the CPU uses during operation.

Keyboard

Used to enter text or control items on the screen.

Mouse

Used to point to and select items on your computer screen.

Monitor

Displays information in visual form using text and graphics.


Horizontal Way
[horizontal]
CPU:: The brain of the computer.
Hard drive:: Permanent storage for operating system and/or user files.
RAM:: Temporarily stores information the CPU uses during operation.
CPU

The brain of the computer.

Hard drive

Permanent storage for operating system and/or user files.

RAM

Temporarily stores information the CPU uses during operation.


Another Way
Dairy::
* Milk
* Eggs
Bakery::
* Bread
Produce::
* Bananas
Dairy
  • Milk

  • Eggs

Bakery
  • Bread

Produce
  • Bananas


A hybrid list

Operating Systems::
  Linux:::
    . Fedora
      * Desktop
    . Ubuntu
      * Desktop
      * Server
  BSD:::
    . FreeBSD
    . NetBSD

Cloud Providers::
  PaaS:::
    . OpenShift
    . CloudBees
  IaaS:::
    . Amazon EC2
    . Rackspace
Operating Systems
Linux
  1. Fedora

    • Desktop

  2. Ubuntu

    • Desktop

    • Server

BSD
  1. FreeBSD

  2. NetBSD

Cloud Providers
PaaS
  1. OpenShift

  2. CloudBees

IaaS
  1. Amazon EC2

  2. Rackspace


A list with complex content

* The header in AsciiDoc must start with a document title.
+
----
= Document Title
----
+
Keep in mind that the header is optional.

* Optional Author and Revision information immediately follows the header title.
+
----
= Document Title
Doc Writer <doc.writer@asciidoc.org>
v1.0, 2013-01-01
----
  • The header in AsciiDoc must start with a document title.

    = Document Title

    Keep in mind that the header is optional.

  • Optional Author and Revision information immediately follows the header title.

    = Document Title
    Doc Writer <doc.writer@asciidoc.org>
    v1.0, 2013-01-01


link:url[optional link text, optional target attribute, optional role attribute]

link:http://www.hmtmcse.com[HMTMCSE]

link:http://www.hmtmcse.com[HMTMCSE in New Window, window=_blank]


Anatomy of a Images macro

image::url[optional link text, optional target attribute, optional role attribute]

image::https://avatars2.githubusercontent.com/u/1875791?s=460&v=4[HMTMCSE, 300, 300]
image::https://avatars2.githubusercontent.com/u/1875791?s=460&v=4[HMTMCSE]
image:https://avatars2.githubusercontent.com/u/1875791?s=460&v=4[HMTMCSE, 100, 100, title="Touhid Mia"]
HMTMCSE
HMTMCSE

HMTMCSE


Table

Example 1

[cols=2*]
|===
|Firefox
|Web Browser

|Ruby
|Programming Language

|TorqueBox
|Application Server
|===

Firefox

Web Browser

Ruby

Programming Language

TorqueBox

Application Server


Example 2

[cols=2*,options=header]
|===
|Name
|Group

|Firefox
|Web Browser

|Ruby
|Programming Language
|===
Name Group

Firefox

Web Browser

Ruby

Programming Language


Example 3

|===
|Name |Group |Description

|Firefox
|Web Browser
|Mozilla Firefox is an open-source web browser.
It's designed for standards compliance,
performance, portability.

|Ruby
|Programming Language
|A programmer's best friend.
|===
Name Group Description

Firefox

Web Browser

Mozilla Firefox is an open-source web browser. It’s designed for standards compliance, performance, portability.

Ruby

Programming Language

A programmer’s best friend.


Example 4

You can set the relative widths of each column using column specifiers—a comma-separated list of relative values defined in the cols block attribute. The number of entries in the list determines the number of columns.

[cols="2,3,5"]
|===
|Name |Group |Description

|Firefox
|Web Browser
|Mozilla Firefox is an open-source web browser.
It's designed for standards compliance,
performance and portability.

|Ruby
|Programming Language
|A programmer's best friend.
|===
Name Group Description

Firefox

Web Browser

Mozilla Firefox is an open-source web browser. It’s designed for standards compliance, performance and portability.

Ruby

Programming Language

A programmer’s best friend.


Example 5

If you want to include blocks or lists inside the contents of a column, you can put an a (for AsciiDoc) at the end of the column’s relative value.

[cols="2,3,5a"]
|===
|Name |Group |Description

|Firefox
|Web Browser
|Mozilla Firefox is an open-source web browser.
It's designed for:

* standards compliance,
* performance and
* portability.

|Ruby
|Programming Language
|A programmer's best friend.
|===
Name Group Description

Firefox

Web Browser

Mozilla Firefox is an open-source web browser. It’s designed for:

  • standards compliance,

  • performance and

  • portability.

Ruby

Programming Language

A programmer’s best friend.

Note

Alternatively, you can apply the AsciiDoc style to an individual cell by prefixing the vertical bar with an a:

a|Mozilla Firefox is an open-source web browser.
It's designed for:

* standards compliance,
* performance and
* portability.


Example code at table cell

[cols="2,2,5"]
|===
|Blocks |Phases |Description

|given:
|Setup
a| The given block is where you do any setup work for the feature that you are describing. It may not be preceded by other blocks, and may not be repeated.
----
given:
def stack = new Stack()
def elem = "push me"
----
|===
Blocks Phases Description

given:

Setup

The given block is where you do any setup work for the feature that you are describing. It may not be preceded by other blocks, and may not be repeated.

given:
def stack = new Stack()
def elem = "push me"



Example 6

[%header,format=csv]
|===
Artist,Track,Genre
Baauer,Harlem Shake,Hip Hop
The Lumineers,Ho Hey,Folk Rock
|===
Artist Track Genre

Baauer

Harlem Shake

Hip Hop

The Lumineers

Ho Hey

Folk Rock

Note

using an include::[] directive:

[%header,format=csv]
|===
 include::tracks.csv[]
|===


Example 7

,===
a,b,c
,===

:===
a:b:c
:===

a

b

c

a

b

c


Table Column Formatting

To apply a specifier to a column, we must set the cols attribute and assign it a value. A column specifier can contain any of the following components:

Multiplier

The multiplier operator (*) is used when you want a specifier to apply to more than one consecutive column. If used, the multiplier must always be placed at the beginning of the specifier.

[cols="3*"]
|===
|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 3, row 1
|===

Cell in column 1, row 1

Cell in column 2, row 1

Cell in column 3, row 1

Align
  1. Left <

  2. Right >

  3. Center ^

[cols="<,^,>"]
|===
|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 2, row 1


|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2
|===

Cell in column 1, row 1

Cell in column 2, row 1

Cell in column 3, row 1

Cell in column 1, row 2

Cell in column 2, row 2

Cell in column 3, row 2

Note
The content in the examples above is only centered on the horizontal. It can also be aligned vertically when the alignment operator is prefixed with a dot (.).
Width

The width component sets the width of a column. Its value can be a proportional integer (the default is 1) or a percentage (1 to 99). We do not need to include the percent sign (%).

[cols="1,2,6"]
|===
|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 3, row 1
|===

Cell in column 1, row 1

Cell in column 2, row 1

Cell in column 3, row 1

Style
Style Name Value Description

AsciiDoc

a

Supports block-level elements (paragraphs, delimited blocks, and block macros). This style effectively creates a nested, standalone AsciiDoc document. Implicit attributes such as doctitle from the parent document will be shadowed. Custom attributes are inherited.

Emphasis

e

Text is italicized

Header

h

Header styles are applied to the column

Literal

l

Column content is treated as if it were inside a literal block

Monospaced

m

Text is rendered in monospaced font

None (default style)

d

Text is handled like a normal paragraph. Supports all markup (i.e., inline formatting, inline macros) that is permitted in a paragraph.

Strong

s

Text is bolded

Verse

v

Column content is treated as if it were inside a verse block

[cols="h,m,s,e,a"]
|===
|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 3, row 1
|Cell in column 4, row 1
|
[java]
----
Integer i = 10;
----
|===

Cell in column 1, row 1

Cell in column 2, row 1

Cell in column 3, row 1

Cell in column 4, row 1

Integer i = 10;


All Togather
[cols=".<2,.^5,^.>3"]
|===
|Cell in column 1, row 1 with lots and lots and lots and lots of content
|Cell in column 2, row 1
|Cell in column 3, row 1

|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2 and another bucket of content, and then a jelly roll of content
|===

Cell in column 1, row 1 with lots and lots and lots and lots of content

Cell in column 2, row 1

Cell in column 3, row 1

Cell in column 1, row 2

Cell in column 2, row 2

Cell in column 3, row 2 and another bucket of content, and then a jelly roll of content


Cell Formatting

Span
  1. * : To duplicate a cell in multiple, consecutive columns, prefix the | with the multiplication factor and the * operator.

  2. ** : To have a cell span multiple, consecutive columns, prefix the `|` with the span factor and the `` operator.

  3. . : If we want to have a cell span multiple, consecutive rows, prefix the span factor with a dot (.). Of course we can combine spanning over columns and rows. The number before the dot (.) is the number of columns to span and the number after the dot (.) is the number of rows to span.

|===
|Cell in column 1, row 1 |Cell in column 2, row 1 |Cell in column 3, row 1 |Cell in column 4, row 1

4*|Same cell content in columns 1, 2, 3 and 4

4+|Content in a single cell that spans columns 1, 2, 3 and 4

|Cell in column 1, row 4
|Cell in column 2, row 4
|Cell in column 3, row 4
|Cell in column 4, row 4

|Cell in column 1, row 5
2.2+| Marge column 1, 2 and Row 5, 6
|Cell in column 4, row 5

|Cell in column 1, row 6
|Cell in column 4, row 6
|===
Cell in column 1, row 1 Cell in column 2, row 1 Cell in column 3, row 1 Cell in column 4, row 1

Same cell content in columns 1, 2, 3 and 4

Same cell content in columns 1, 2, 3 and 4

Same cell content in columns 1, 2, 3 and 4

Same cell content in columns 1, 2, 3 and 4

Content in a single cell that spans columns 1, 2, 3 and 4

Cell in column 1, row 4

Cell in column 2, row 4

Cell in column 3, row 4

Cell in column 4, row 4

Cell in column 1, row 5

Marge column 1, 2 and Row 5, 6

Cell in column 4, row 5

Cell in column 1, row 6

Cell in column 4, row 6

Cell in column 1, row 7

Cell in column 2, row 7

Cell in column 3, row 7

Cell in column 4, row 7


Admonitions

  1. NOTE

  2. TIP

  3. IMPORTANT

  4. CAUTION

  5. WARNING


NOTE

NOTE: Wolpertingers are known to nest in server racks.
Enter at your own risk.
Note
Wolpertingers are known to nest in server racks. Enter at your own risk.


TIP

TIP: This is Example text for describe something.
Tip
This is Example text for describe something.


IMPORTANT

IMPORTANT: This is Example text for describe something.
Important
This is Example text for describe something.


CAUTION

CAUTION: This is Example text for describe something.
Caution
This is Example text for describe something.


WARNING

WARNING: This is Example text for describe something.
Warning
This is Example text for describe something.


Include Files

 include::basics.adoc[]
 include::installation.adoc[]
 include::example.adoc[]

Video

Normal video Embed

video::/path/to/video_file.mp4[]
video::video_file.mp4[width=640, start=60, end=140, options=autoplay]


YouTube video Embed

video::xM80Idt9JZ8[youtube, width=250, height=200]


Vimeo video Embed

video::401333513[vimeo]