10

Using Sphinx 1.2.3 and given this RST snippet:

.. code-block:: xml

    <foo>
        <bar>|version|</bar>
    </foo>

and in conf.py I have:

version = '1.0.2'

How do you ensure that the above RST snippet renders as:

<foo>
    <bar>1.0.2</bar>
</foo>

This previous question indicates that we should use .. parsed-literal:: instead of .. code-block::, but that does not work, nor does the referenced link in that question work either.

I also want to retain syntax highlighting.

Community
  • 1
  • 1
Les Hazlewood
  • 18,480
  • 13
  • 68
  • 76
  • Here is how you can get the substitution working: http://stackoverflow.com/a/25557867/407651. But it is not possible to also retain syntax highlighting (see http://stackoverflow.com/q/27185467/407651). – mzjn Dec 10 '14 at 08:03
  • @mzjn thanks for the comment - if you want to provide a normal answer, I'll award it. Thanks! – Les Hazlewood Dec 10 '14 at 21:29

1 Answers1

6

You can get the wanted output by using backslash-escaped whitespace:

.. parsed-literal::

  <foo>
       <bar>\ |release|\ </bar>
  </foo>

Unfortunately it is not possible to also retain syntax highlighting (you can get that with the code-block directive of course, but then the substitution won't work).

mzjn
  • 48,958
  • 13
  • 128
  • 248