【问题标题】:How to create proper heading levels with rst2html如何使用 rst2html 创建适当的标题级别
【发布时间】:2019-01-09 10:50:54
【问题描述】:

我不明白为什么:

H1: document title
##################

Sample H2
*********
Sample content.

结果:

<div class="document" id="h1-document-title">
<h1 class="title">H1: document title</h1>
<h2 class="subtitle" id="sample-h2">Sample H2</h2>

<p>Sample content.</p>
</div>

H1: document title
##################

Sample H2
*********
Sample content.

Sample H3
*********
Sample content.

结果:

<div class="document" id="h1-document-title">
<h1 class="title">H1: document title</h1>

<div class="section" id="sample-h2">
<h1>Sample H2</h1>
<p>Sample content.</p>
</div>
<div class="section" id="sample-h3">
<h1>Sample H3</h1>
<p>Sample content.</p>
</div>

即我不能有一个 h1 元素后跟多个 h2。谢谢。

【问题讨论】:

    标签: html restructuredtext docutils


    【解决方案1】:

    这是关于文档标题和副标题的解释。如果第一个标题的修饰在文档中是唯一的,则将其解释为文档标题。如果第二个标题紧跟在第一个标题之后,并带有另一个独特的装饰,则将其视为副标题。

    http://docutils.sourceforge.net/docs/user/rst/quickstart.html#document-title-subtitle

    例子:

    Document title
    ##############
    
    Subtitle
    .........
    
    Heading 1
    *********
    Sample content.
    
    Heading 2
    ---------
    Sample content.
    
    Heading 3
    ---------
    Sample content.
    

    通过这个标记,rst2html 将生成带有如下标题的 HTML:

    • 文档标题:&lt;h1&gt;(居中)
    • 字幕:&lt;h2&gt;(居中)
    • 标题1:&lt;h1&gt;
    • 标题 2:&lt;h2&gt;
    • 标题3:&lt;h2&gt;

    【讨论】:

    • 感谢您的澄清。如果我们不需要标题和副标题,而只想使用标题怎么办?
    • 好的,我想我找到了解决方案:stackoverflow.com/questions/23936768/…
    • 如果用于第一个标题的装饰不是唯一的,那么您有一个“只有标题”的文档。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-31
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多