我正在使用Sphinx为Python程序生成HTML文档。
我想使用带有特定标题的通用admonition
指令(参见http://docutils.sourceforge.net/docs/ref/rst/directives.html#generic-admonition),并以一种我可以定义的方式对其进行标记,例如,使用note
指令生成的内容(如盒装)但使用不同的颜色(大多数警告不是特制的,请参见http://sphinx.pocoo.org/rest.html?highlight=admonition)。
我该怎么办?
最佳答案
如果我正确理解了您的问题,那么您想对这种警告应用custon CSS样式。您可以使用:class:attibute来做到这一点。
例如,以下
.. admonition:: my title goes here
:class: myOwnStyle
this is the admonition text
呈现为
<div class="myownstyle admonition">
<p class="first admonition-title">my title goes here</p>
<p class="last">this is the admonition text</p>
</div>
然后,您添加自己的样式表。例如,通过在源目录的_templates目录中的custom layout.html:
{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/customstyle.css"] %}
然后,您可以使用myownstyle类的选择器在样式表中使用CSS样式
关于markup - 定义带有特定标题的通用狮身人面像标记的标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9162891/