Conditional Rendering of Content

Define paragraphs in the document that show or hide when the document previewed in the IDE.

Situation

A user wants to show or hide paragraphs within a document when it is previewed in the IDE.

Solution

IntelliJ sets the variables env-idea and env so that the user can render the texts differently when working with the Asciidoc plugin.

The plugin sets the variable env-idea to defined, therefore the following works:

ifndef::env-idea[]
Render this text WHEN NOT running IntelliJ Asciidoctor Plugin.
endif::[]

ifdef::env-idea[]
Render this text IF running IntelliJ Asciidoctor Plugin.
endif::[]

The plugin sets the variable env to the value idea, therefore the following works:

ifeval::[{env}!=idea]
render this text WHEN NOT running IntelliJ Asciidoctor Plugin
endif::[]

ifeval::[{env}==idea]
render this text IF running IntelliJ Asciidoctor Plugin
endif::[]

Further reading