1

对于一个文档项目,我想给出代码示例作为项目符号列表。我使用 Sphinx 将 .rst 文件转换为 HTML。这很好用,直到我开始在列表项中使用文字块。在下面的示例中,我想在与“给定一个 XML 文件...”相同的级别上显示句子“执行以下代码之后”。但是它会自动缩进。

Example
--------

-   Given an XML-file note.xml, which contains:

    ::

        <note>
            <to>Tove</to>
            <from>Jani</from>
            <heading>Reminder</heading>
            <body>Don't forget me this weekend!</body>
        </note>

    After executing the following code:

    ::

        xml = loadxml ("<your path to file>/note.xml");
        parent = xpath(xml, "//note"); //get main node
        addsubnode (parent, "<comment>Comments are welcome.</comment>");

PS:别管代码,它是一种特殊的语言。

4

1 回答 1

3

偶然发现了解决方案。事实证明非常简单,只需将项目符号后面的行留空即可:

Examples
--------

-   

    Given an XML-file note.xml, which contains:

    ::

        <note>
            <to>Tove</to>
            <from>Jani</from>
            <heading>Reminder</heading>
            <body>Don't forget me this weekend!</body>
        </note>

    After executing the following code:

    ::

        xml = loadxml ("<your path to file>/note.xml");
        parent = xpath(xml, "//note"); //get main node
        addsubnode (parent, "<comment>Comments are welcome.</comment>");
于 2013-07-26T11:32:57.460 回答