markup - 定义带有特定标题的通用狮身人面像标记的标记

标签 markup python-sphinx restructuredtext

我正在使用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/

相关文章:

html - 我应该在标记中使用 <p/> 标签吗?

html - 为什么 Bootstrap 将最后一列移动到下一行?

html - 我可以在 GitLab 上渲染 HTML 吗?

windows - 如何在 Windows 中使用 Sphinx 创建 PDF 文档

css - 如何更改 reStructuredText 中表格单元格的背景颜色?

html - 无法仅针对 CSS 中的一个无序列表

python-sphinx - 从 sphinx 函数中删除包和模块名称

python - 如何通过 sphinx 链接到 Python 3 文档中的类型 contextmanager 标签

python - RestructuredText - 没有前导和尾随空格的超链接

css - 在 CSS HTML 中对齐翻转卡片