Conditional Rendering of Content

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

Situation

A user wants 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 only WHEN NOT running IntelliJ Asciidoctor Plugin
endif::[]

ifdef::env-idea[]
render this text only ONLY 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 only WHEN NOT running IntelliJ Asciidoctor Plugin
endif::[]

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

Further reading