Apply Substitutions

The subs attribute

Specific substitution elements can be applied to any block or paragraph by setting the subs attribute. The subs attribute can be assigned a comma-separated list of the following substitution elements and groups.


Disables substitutions


Performs all substitutions except for callouts


Replaces special characters and processes callouts

specialchars, specialcharacters

Replaces <, >, and & with their corresponding entities


Applies text formatting


Replaces attribute references


Substitutes textual and character reference replacements


Processes macros


Replaces the line break character (+)

Let’s look at an example where you only want to process special characters, formatting markup, and callouts in a literal block. By default, literal blocks are only subject to special characters substitution. But you can change this behavior by setting the subs attribute in the block’s attribute list.

[source,java,subs="verbatim,quotes"] (1)
System.out.println("Hello *bold* text"). (2)
1 The subs attribute is set in the attribute list and assigned the verbatim and quotes values.
2 The formatting markup in this line will be replaced when the quotes substitution runs.
System.out.println("Hello bold text"). (1) (2)
1 The verbatim value enables the callouts to be processed.
2 The quotes value enables the text formatting to be processed.

If you are applying the same set of substitutions to numerous blocks, you should consider making them an attribute entry to ensure consistency.

:markup-in-source: verbatim,quotes

System.out.println("Hello *bold* text").

Another way to ensure consistency and keep your documents clean and simple is to use the extensions::tree-processor.adoc.

Incremental substitutions

When you set the subs attribute on a block, you automatically remove all of its default substitutions. For example, if you set subs on a literal block, and assign it a value of attributes, only attributes are substituted. The verbatim substitution will not be applied. To remedy this situation, Asciidoctor provides a syntax to append or remove substitutions instead of replacing them outright.

You can add or remove a substitution from the default substitution list using the plus (+) and minus (-) modifiers. These are known as incremental substitutions.


Prepends the substitution to the default list.


Appends the substitution to the default list.


Removes the substitution from the default list.

For example, you can add the attributes substitution to a listing block’s default substitution list.

Add attributes substitution to a default substitution list

Similarly, you can remove the callouts substitution.

Remove callouts substitution from a default substitution list
.An illegal XML tag

You can also specify whether the substitution is placed at the beginning or end of the substitution list. If a + comes before the name of the substitution, then it’s added to the end of the existing list, and if a + comes after the name, it’s added to the beginning of the list.

<copyright>(C) ACME</copyright>
content in 1 element

In the above example, the quotes, then the special characters, and then the attributes substitutions will be applied to the listing block.

Apply substitutions to inline elements

Custom substitutions can also be applied to some inline elements, such as the pass macro.

For example, the quotes text substitution value is assigned in the inline pass macro below.

The text pass:q[<u>underline *me*</u>] is underlined and the word "`me`" is bold.

The text underline me is underlined and the word “me” is bold.