Diffierent text output depending upon the backend in use

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Diffierent text output depending upon the backend in use

taxi
This post was updated on .
While writing a document , how to use conditionals in asciidoctor, so that:
  (a) I can output different text if I am outputting PDF
  (b) and i can output different text when i am outputting html.
Something like this "PSEUDO-CODE" as following:

# My Test Document #

## Section 1 ##


line1

ifeval::[{document.basebackend} = "pdf"]
  line2
elseifeval::[{document.basebackend} = "html5"]
  line3
else::[]
  line4
endif::[]

line5 
Reply | Threaded
Open this post in threaded view
|

Re: Diffierent text output depending upon the backend in use

mojavelinux
Administrator
This feature is not yet documented in the Asciidoctor user manual. For information about it, please see the open issue.


Not that there is always an attribute set for the current backend and doctype that you can use. For instance, when using the html5 backend, you can write:

ifdef::backend-html5[]
do stuff for html5
endif::[]

or

ifdef::doctype-article[]
do stuff for the article doctype
endif::[]

There's also a slightly less well-defined basebackend attribute. This usually just drops the version number from the backend.

ifdef::basebackend-html[]
do stuff for html
endif::[]

However, it's no always parallel. The basebackend for Asciidoctor PDF is also basebackend-html. It's up to the converter to decide this setting.

I hope that helps a bit!

Cheers,

-Dan

On Sat, Jul 18, 2015 at 10:47 PM, taxi [via Asciidoctor :: Discussion] <[hidden email]> wrote:
While writing a document , how to use conditionals in asciidoctor, so that I can output different text if I am outputting PDF and i can output different text when i am outputting html. Something like this "PSEUDO-CODE" as following:


# My Test Document

## Section 1 ##


line1

ifeval::[{outputformat} = "pdf"]
  line2
elseifeval::[{outputformat} = "html5"]
  line3
else::[]
  line4
endif::[]

line5


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Diffierent-text-output-depending-upon-the-backend-in-use-tp3517.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--