gpt4 book ai didi

python-sphinx - reStructuredText 页面中的非目录标题

转载 作者:行者123 更新时间:2023-12-04 06:10:50 29 4
gpt4 key购买 nike

我正在使用 Sphinx 编写一些文档。

有没有办法在页面中格式化不成为 TOC 一部分的标题?
理想情况下,某些层次结构反射(reflect)在格式中?

例如。我想要做

My page TOC heading
===================

Subheading (not in TOC, and should be formatted e.g. smaller than the heading)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Sub-subheading (not in TOC, and formatted e.g. smaller than the subheading)
###########################################################################

也欢迎任何其他关于如何标记文本以使其具有更结构化外观的建议。

最佳答案

您可以为模仿标题样式的量规创建自定义样式。

(1) 在您的 ReST 源中,像这样定义自定义样式:

.. role:: style1
:class: class1

.. role:: style2
:class: class2

这里的“style_”是在 ReST 中引用这些的句柄,“class_”是 CSS 类名。

(2) 将上述内容用作 rubrics 中的内联样式:
.. rubric:: :style1:`fake H1`

.. rubric:: :style2:`fake H2`

(3) 在任何有意义的 CSS 文件中,为新类定义样式:
.rubric > .class1 {
whatever
}

.rubric > .class2 {
whatever
}

如果您愿意,这里的“任何”可以与 H1、H2 等的现有样式相同。

注意:在步骤 (3) 中,您可以更宽泛或更窄地定义 CSS 选择器。如果新的类名是全局唯一的,选择器可以像 .class1 一样简单。 ;或者,如果您想像我的示例一样仅将样式用于顶级量规,您可以使用 p.rubric > span.class1反而。

关于python-sphinx - reStructuredText 页面中的非目录标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19069405/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com