Skip to content
Advertisement

Substitutions next to angle brackets in Sphinx

I’m trying to use substitutions in a parsed literal block in my Sphinx documentation like this:

<dependency>
  ...
  <version>|release|</version>
</dependency>

Which gets rendered like this:

<dependency>
  ...
  <version>|release|</version>
</dependency>

Where what I want is this:

<dependency>
  ...
  <version>1.7.3</version>
</dependency>

If I add spaces around the substitution in the source, I get this:

<dependency>
  ...
  <version> 1.7.3 </version>
</dependency>

So I know release is defined as I expect. How can I get rid of the spaces?

Advertisement

Answer

This works:

.. parsed-literal::

   <version> |release| </version>

.. |release| replace:: 1.7.3

Reference: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#escaping-mechanism

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement