Sphinx substitutions next to angle brackets

橙三吉。 提交于 2019-12-24 06:38:16

问题


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?


回答1:


This works:

.. parsed-literal::

   <version>\ |release|\ </version>

.. |release| replace:: 1.7.3

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



来源:https://stackoverflow.com/questions/25557602/sphinx-substitutions-next-to-angle-brackets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!