重组文本页面内的非TOC标题 [英] Non-TOC headings within a Restructuredtext page

查看:104
本文介绍了重组文本页面内的非TOC标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



例如。我想做

 我的页面TOC标题
============ =====

副标题(不在TOC中,应格式化为小于标题)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

子子标题(不在TOC中,格式化为小于副标题)
########################## ##################################################### b

还欢迎任何其他建议如何标记文本,以便读者具有更加结构化的外观。

解决方案

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



(1)在您的ReST源中,定义如下所示的自定义样式:

  .. role :: style1 
:class class1

..角色:: style2
:class:class2

这里style_是在ReST中引用这些的句柄,class_是C SS类名称。



(2)使用以上内容作为内容样式:

 code> .. rubric :::style1:`fake H1` 

.. rubric :::style2:`fake H2`
pre>

(3)在任何CSS文件中,定义新类的样式:

  .rubric> .class1 {
无论
}

.rubric> .class2 {
无论
}

这里任何可能是相同的对于H1,H2等的现有样式,如果您愿意的话。



注意:在步骤(3)中,您可以更广泛地或狭义地定义CSS选择器。如果新的类名称是全局唯一的,则选择器可以像 .class1 一样简单;或者如果要使用像我的示例一样的顶级标题的样式,可以使用 p.rubric> span.class1


I'm writing some documentation using Sphinx.

Is there a way to format headings within a page which do not become part of the TOC? Ideally with some hierarchy that is reflected in formatting?

E.g. I want to do

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)
###########################################################################

Any other suggestions for how to markup the text so that it has a more structured appearance for the reader are also welcome.

解决方案

You can create custom styles for rubrics that mimic your heading styles.

(1) In your ReST source, define custom styles like this:

.. role:: style1
    :class: class1

.. role:: style2
    :class: class2

Here "style_" is the handle to refer to these in ReST, and "class_" is the CSS class name.

(2) Use the above as inline styles in rubrics:

.. rubric:: :style1:`fake H1`

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

(3) In whatever CSS file makes sense, define styles for the new classes:

.rubric > .class1 {
    whatever
}

.rubric > .class2 {
    whatever
}

Here the "whatever" could be identical to existing styles for H1, H2 etc. if you wish.

Note: in step (3), you could define the CSS selectors more broadly or narrowly. If the new class names are globally unique, the selector could be as simple as .class1; or if you want to use the style just for top-level rubrics like my example, you could use p.rubric > span.class1 instead.

这篇关于重组文本页面内的非TOC标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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