Safe Mode Specific Content

Asciidoctor provides access to the current safe mode through built-in attributes. You can use these attributes to enable or disable content based on the current safe mode of the processor.

Referencing safe modes

The safe mode can be referenced by one of the following document attributes:

  • The value of the safe-mode-name attribute (e.g., unsafe, safe, etc.)

  • The value of the safe-mode-level attribute (e.g., 0, 10, etc.)

  • The presence of the safe-mode-<name> attribute, where <name> is the safe mode name.

The attributes in the next example define replacement text for features that are disabled in high security environments:

ifdef::safe-mode-secure[]
Link to chapters instead of including them.
endif::safe-mode-secure[]

This feature is particularly handy for displaying content on GitHub, where the safe mode is set to its most restrictive setting, SECURE.

You can set the safe mode from the CLI and the API.