Sphinx 代码块内的替换不会被替换
在这个由 Sphinx 渲染的 reST 示例中,|yaco_url|不会被替换,因为它位于代码块中:
.. |yaco_url| replace:: http://yaco.es/
You can use wget to download it:
.. code-block:: console
$ wget |yaco_url|package.tar.gz
我想知道是否有某种方法可以强制替换 |yaco_url|在渲染代码块之前。
In this reST example meant to be rendered by Sphinx, |yaco_url| doesn't get replaced because it's in a code-block:
.. |yaco_url| replace:: http://yaco.es/
You can use wget to download it:
.. code-block:: console
$ wget |yaco_url|package.tar.gz
I wonder if there is some way to force the replacement of |yaco_url| before rendering the code block.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用“parsed-literal”指令。
来源:https://groups.google.com/forum/?fromgroups=#!主题/sphinx-dev/ABzaUiCfO_8:
Use the "parsed-literal" directive.
Source: https://groups.google.com/forum/?fromgroups=#!topic/sphinx-dev/ABzaUiCfO_8:
找到了一个更好的解决方案(在我看来),可以在
:samp:
等其他指令中使用,并且可能对未来的读者有用。config.py:
这种标记:
正确生成如下:
注意,如果使用它来替换
:samp:
指令中的参数,则双括号{
是要求。来源:https://github.com/sphinx-doc/sphinx/issues/4054
Found a better solution (in my opinion), that can be used in others directives like
:samp:
and might be useful for future readers.config.py:
And this kind of markup:
Properly generates like:
Note, that if using this to replace an argument in the
:samp:
directive, a double bracket{
is require.source: https://github.com/sphinx-doc/sphinx/issues/4054