13. Delimited Blocks

Delimited blocks are blocks of text enveloped by leading and trailing delimiter lines (normally a series of four or more repeated characters). The behavior of Delimited Blocks is specified by entries in configuration file [blockdef-*] sections.

13.1. Predefined Delimited Blocks

AsciiDoc ships with a number of predefined DelimitedBlocks (see the asciidoc.conf configuration file in the asciidoc(1) program directory):

Predefined delimited block underlines:

CommentBlock:     //////////////////////////
PassthroughBlock: ++++++++++++++++++++++++++
ListingBlock:     --------------------------
LiteralBlock:     ..........................
SidebarBlock:     **************************
QuoteBlock:       __________________________
ExampleBlock:     ==========================
OpenBlock:        --

The code, source and music filter blocks are detailed in the Filters section.

Table 1. Default DelimitedBlock substitutions

Attributes Callouts Macros Quotes ReplacementsSpecial chars Special words

PassthroughBlock

Yes

No

Yes

No

No

No

No

ListingBlock

No

Yes

No

No

No

Yes

No

LiteralBlock

No

Yes

No

No

No

Yes

No

SidebarBlock

Yes

No

Yes

Yes

Yes

Yes

Yes

QuoteBlock

Yes

No

Yes

Yes

Yes

Yes

Yes

ExampleBlock

Yes

No

Yes

Yes

Yes

Yes

Yes

OpenBlock

Yes

No

Yes

Yes

Yes

Yes

Yes


13.2. Listing Blocks

ListingBlocks are rendered verbatim in a monospaced font, they retain line and whitespace formatting and are often distinguished by a background or border. There is no text formatting or substitutions within Listing blocks apart from Special Characters and Callouts. Listing blocks are often used for computer output and file listings.

Here’s an example:

--------------------------------------
#include <stdio.h>

int main() {
   printf("Hello World!\n");
   exit(0);
}
--------------------------------------

Which will be rendered like:

#include <stdio.h>

int main() {
    printf("Hello World!\n");
    exit(0);
}

By convention filter blocks use the listing block syntax and are implemented as distinct listing block styles.

13.3. Literal Blocks

LiteralBlocks are rendered just like literal paragraphs. Example:

...................................
Consul *necessitatibus* per id,
consetetur, eu pro everti postulant
homero verear ea mea, qui.
...................................

Renders:

Consul *necessitatibus* per id,
consetetur, eu pro everti postulant
homero verear ea mea, qui.

If the listing style is applied to a LiteralBlock it will be rendered as a ListingBlock (this is handy if you have a listing containing a ListingBlock).

13.4. Sidebar Blocks

A sidebar is a short piece of text presented outside the narrative flow of the main text. The sidebar is normally presented inside a bordered box to set it apart from the main text.

The sidebar body is treated like a normal section body.

Here’s an example:

.An Example Sidebar
************************************************
Any AsciiDoc SectionBody element (apart from
SidebarBlocks) can be placed inside a sidebar.
************************************************

Which will be rendered like:

Apply the abstract style to generate an abstract, for example:

[abstract]
************************************************
In this paper we will ...
************************************************

13.5. Comment Blocks

The contents of CommentBlocks are not processed; they are useful for annotations and for excluding new or outdated content that you don’t want displayed. CommentBlocks are never written to output files. Example:

//////////////////////////////////////////
CommentBlock contents are not processed by
asciidoc(1).
//////////////////////////////////////////

See also Comment Lines.

[Note]Note

System macros are executed inside comment blocks.

13.6. Passthrough Blocks

By default the block contents is subject only to attributes and macros substitutions (use an explicit subs attribute to apply different substitutions). PassthroughBlock content will often be backend specific. Here’s an example:

[subs="quotes"]
++++++++++++++++++++++++++++++++++++++
<table border="1"><tr>
  <td>*Cell 1*</td>
  <td>*Cell 2*</td>
</tr></table>
++++++++++++++++++++++++++++++++++++++

The following styles can be applied to passthrough blocks:

pass
No substitutions are performed. This is equivalent to subs="none".
asciimath, latexmath
By default no substitutions are performed, the contents are rendered as mathematical formulas.

13.7. Quote Blocks

QuoteBlocks are used for quoted passages of text. There are two styles: quote and verse. The style is set by the first positional attribute, if no style attribute is specified the quote style. The optional attribution and citetitle attributes (positional attributes 2 and 3) specify the quote’s author and source.

The quote style treats the content like a SectionBody, for example:

[quote, Bertrand Russell, The World of Mathematics (1956)]
____________________________________________________________________
A good notation has subtlety and suggestiveness which at times makes
it almost seem like a live teacher.
____________________________________________________________________

Which is rendered as:

 

A good notation has subtlety and suggestiveness which at times makes it almost seem like a live teacher.

 
 -- Bertrand Russell The World of Mathematics (1956)

The verse style retains the content’s line breaks, for example:

[verse, William Blake, from Auguries of Innocence]
__________________________________________________
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.
__________________________________________________

Which is rendered as:

 

To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

 
 -- William Blake from Auguries of Innocence

13.8. Example Blocks

ExampleBlocks encapsulate the DocBook Example element and are used for, well, examples. Example blocks can be titled by preceding them with a BlockTitle. DocBook toolchains will normally automatically number examples and generate a List of Examples backmatter section.

Example blocks are delimited by lines of equals characters and can contain any block elements apart from Titles, BlockTitles and Sidebars) inside an example block. For example:

.An example
=====================================================================
Qui in magna commodo, est labitur dolorum an. Est ne magna primis
adolescens.
=====================================================================

Renders:

Example 1. An example

Qui in magna commodo, est labitur dolorum an. Est ne magna primis adolescens.


A title prefix that can be inserted with the caption attribute (xhtml11 and html4 backends). For example:

[caption="Example 1: "]
.An example with a custom caption
=====================================================================
Qui in magna commodo, est labitur dolorum an. Est ne magna primis
adolescens.
=====================================================================

13.9. Admonition Blocks

The ExampleBlock definition includes a set of admonition styles (NOTE, TIP, IMPORTANT, WARNING, CAUTION) for generating admonition blocks (admonitions containing more than a single paragraph). Just precede the ExampleBlock with an attribute list specifying the admonition style name. For example:

[NOTE]
.A NOTE admonition block
=====================================================================
Qui in magna commodo, est labitur dolorum an. Est ne magna primis
adolescens.

. Fusce euismod commodo velit.
. Vivamus fringilla mi eu lacus.
  .. Fusce euismod commodo velit.
  .. Vivamus fringilla mi eu lacus.
. Donec eget arcu bibendum
  nunc consequat lobortis.
=====================================================================

Renders:

[Note]A NOTE admonition block

Qui in magna commodo, est labitur dolorum an. Est ne magna primis adolescens.

  1. Fusce euismod commodo velit.
  2. Vivamus fringilla mi eu lacus.

    1. Fusce euismod commodo velit.
    2. Vivamus fringilla mi eu lacus.
  3. Donec eget arcu bibendum nunc consequat lobortis.

See also Admonition Icons and Captions.

13.10. Open Blocks

An OpenBlock renders the block contents without any opening or closing tags. The open block start and end delimiter is a single line containing two dashes. Enclosed elements are rendered just as they would inside a section body. Open blocks are used for list item continuation.