August 26, 2014

Awesome Asciidoctor: Conditional Directive to Check If Document is On GitHub

In a previous blog post we learned about the conditional directives in Asciidoctor. Dan Allen mentioned a conditional directive that we can use to see if the document is used on GitHub. The conditional directive is called env-github.

We have the following Asciidoc markup for a document stored on GitHub:


= Asciidoc on GitHub

Sample document for {blogpost}[Aweseome Asciidoc blog post].

This line is only visible if the document is on GitHub.
GitHub is using Asciidoctor {asciidoctor-version}.

ifndef::env-github[This line is visible if not rendered on GitHub.]

To see what is rendered we can view the document on GitHub.

Written with Asciidoctor 1.5.0.