In python-sphinx there is the only directive, which can be used to conditionally influence the document according to its output. For instance text appears in html or latex only.
It is use like this:
.. only:: not latex Here there is some Text, that does not appear in latex output. .. only:: html Here there is some Text, that only appears in html output.
How can I use the role directive in the right way to use the only-class inline, let's say like this:
Here there is some Text, that :only-notlatex:`does not appear in latex`
:only-html:`only appears in html`.
I saw something similar for the raw directive. Is this also possible for the only directive? I tried:
.. role:: only-html(only) :format: html .. role:: only-notlatex(only) :format: not latex
But this does not work.
Sphinx uses interpreted text roles to insert semantic markup into documents. They are written as :rolename:`content` . Note. The default role ( `content` ) has no special meaning by default.
A directive (ref) is a generic block of explicit markup. Along with roles, it is one of the extension mechanisms of reST, and Sphinx makes heavy use of it. Docutils supports the following directives: Admonitions: attention, caution, danger, error, hint, important, note, tip, warning and the generic admonition.
Directives work on blocks of text (whole paragraphs); roles are for inline text (within paragraphs).
You mentioned raw
, and there is indeed both a directive and a role with that name, for "raw data pass-through".
But there is no built-in role that is the inline equivalent of the only
directive. You will have to create your own custom role for this purpose. I can't provide any detailed instructions, but here is an article that can help you get started: http://doughellmann.com/2010/05/09/defining-custom-roles-in-sphinx.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With