Previous: , Up: Conditionally Visible Text   [Contents][Index]

15.7 Conditional Nesting

Conditionals can be nested; however, the details are a little tricky. The difficulty comes with failing conditionals, such as @ifhtml when HTML is not being produced, where the included text is to be ignored. However, it is not to be completely ignored, since it is useful to have one @ifset inside another, for example—that is a way to include text only if two conditions are met. Here’s an example:

@ifset somevar
@ifset anothervar
Both somevar and anothervar are set.
@end ifset
@ifclear anothervar
Somevar is set, anothervar is not.
@end ifclear
@end ifset

Technically, Texinfo requires that for a failing conditional, the ignored text must be properly nested with respect to that failing conditional. Unfortunately, it’s not always feasible to check that all conditionals are properly nested, because then the processors could have to fully interpret the ignored text, which defeats the purpose of the command. Here’s an example illustrating these rules:

@ifset a
@ifset b
@ifclear ok  - ok, ignored
@end junky   - ok, ignored
@end ifset
@c WRONG - missing @end ifset.

Finally, as mentioned above, all conditional commands must be on lines by themselves, with no text (even spaces) before or after. Otherwise, the processors cannot reliably determine which commands to consider for nesting purposes.