替换¶
本地版¶
本地版-
|logo|
代替此图片:// 在最后做如下定义, 在整个文中可用 .. |logo| image:: ../files/image/photo.jpg :width: 20pt :height: 20pt :align: middle 这儿这么用: |logo|
本地版-代替一段话:
.. |longtext| replace:: this is a longish text to include within a table and which is longer than the width of the column. 这儿这么用: |longtext|
这儿这么用: this is a longish text to include within a table and which is longer than the width of the column.
代替原始 html:
.. |raw-html| raw:: html <!-- comment (using replacement) --> <h3>hello</h3> raw代码展示: |raw-html|
raw代码展示:
hello
自定义role:
.. role:: raw-custom(raw) :format: html :raw-custom:`<!-- comment (using role) -->左边是注释(<span style="color:#FF0000;">不显示</span>), 这儿是代码(<b>显示</b>).` **<左边是 raw 代码,这儿是sphinx 语法>**
左边是注释(不显示), 这儿是代码(显示). <左边是 raw 代码,这儿是sphinx 语法>
全局版¶
// In your conf.py:
my_config_value = 42
rst_epilog = '.. |my_conf_val| replace:: %d' % my_config_value
// In your .rst source:
My config value is |my_conf_val|!
// In your output:
My config value is 42!