为具有特定标题的通用狮身人面像警告定义标记 [英] define mark up for generic sphinx admonitions with a specific title

查看:15
本文介绍了为具有特定标题的通用狮身人面像警告定义标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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>
然后添加您自己的样式表。例如,通过目录中的_模板目录中的自定义layout.html
{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/customstyle.css"] %}

然后您可以在样式表中使用myownstyle类的选择器

这篇关于为具有特定标题的通用狮身人面像警告定义标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆