Sphinx 中尖括号旁边的替换 [英] Substitutions next to angle brackets in Sphinx

查看:68
本文介绍了Sphinx 中尖括号旁边的替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 替换://docutils.sourceforge.net/docs/ref/rst/directives.html#parsed-literal-block" rel="nofollow">解析文字块在我的Sphinx 文档 像这样:

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

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

渲染成这样:

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

我想要的是这个:

<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>

所以我知道 release 的定义符合我的预期.我怎样才能摆脱空格?

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

推荐答案

这有效:

.. parsed-literal::

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

.. |release| replace:: 1.7.3

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

这篇关于Sphinx 中尖括号旁边的替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆