And*_*ann 5 restructuredtext inline role python-sphinx
在python-sphinx中有唯一的指令,可以根据其输出用于有条件地影响文档.例如,文本仅出现在html或latex中.
它是这样用的:
.. only:: not latex Here there is some Text, that does not appear in latex output. .. only:: html Here there is some Text, that only appears in html output.
如何以正确的方式使用角色指令来使用唯一类内联,让我们这样说:
Here there is some Text, that :only-notlatex:`does not appear in latex`
:only-html:`only appears in html`.
我看到了raw指令的类似内容.这也是唯一的指令吗?我试过了:
.. role:: only-html(only) :format: html .. role:: only-notlatex(only) :format: not latex
但这不起作用.
指令适用于文本块(整个段落);角色用于内联文本(段落内)。
您提到过raw,确实有一个具有该名称的指令和角色,用于“原始数据传递”。
但没有与该指令等效的内置角色only。为此,您必须创建自己的自定义角色。我无法提供任何详细说明,但这里有一篇文章可以帮助您入门:http://doughellmann.com/2010/05/09/defining-custom-roles-in-sphinx.html。
| 归档时间: |
|
| 查看次数: |
555 次 |
| 最近记录: |