Conditionals

You can include or exclude lines of text in your document using one of the following conditional preprocessor directives:

These directives tell the processor whether to include the enclosed content based on certain conditions. The conditions are based on the presence or value of document attributes.

Conditional processing

Although a conditional preprocessor directive looks like a block macro, it’s not a macro and therefore isn’t processed like one. It’s a preprocessor directive; it’s important to understand the distinction.

A preprocessor directive is processed when the lines of a document are read, but before the document structure is parsed. Therefore, it’s not aware of the surrounding document structure. A preprocessor directive merely adds lines to the reader or takes lines away. The conditional preprocessor directives determine which lines to add and which ones to take away based on the condition.

Escape a conditional directive

If you don’t want a conditional preprocessor directive to be processed, you must escape it using a backslash.

\ifdef::just-an-example[]

Escaping the directive is necessary even if it appears in a verbatim block since it’s not aware of the surrounding document structure.