Conditionals

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

When the processor encounters one of these conditionals, it evaluates the specified condition. The condition is based on the presence or value of one or more document attributes. If the condition evaluates to true, the lines the conditional encloses are included. Otherwise, the lines are skipped.

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.