相关疑难解决方法(0)

代码块不起作用的 reStructuredText 中的嵌套子列表

我正在使用 sphinx 尝试从 .rst 文件创建 HTML 文档。我正在尝试创建一个具有编号列表 (1., 2., ...) 的文档,其中包含一个显示示例代码的嵌套子列表 (a., b, c., ...)。但是我在梳理语法以使嵌套子列表起作用时遇到了麻烦。这.rst是我尝试过的示例文件:

===========
Tester Page
===========

Below are some test paragraphs.

1. This is a paragraph detailing a higher level step, with 3 sub-steps.
 a. This is a sub-bullet, with an example:
::

    ls -l foo.txt

 b. I can't get this line to not display as part of the code block! This is another sub-bullet, with an example:
::

    git add bar.txt

2. This is …
Run Code Online (Sandbox Code Playgroud)

restructuredtext python-sphinx

3
推荐指数
1
解决办法
2894
查看次数

列表项中的结束文字块

我的第一个文件中有一个列表项,我想在其中放入文字块,但我无法让文字块正确结束。

这是我的第一个:

1. Item 1 (not literal)
2. Item 2::

    MyCode.example()

    Description of the code shown above (not literal)
Run Code Online (Sandbox Code Playgroud)

我希望以开头的段落位于Description其上方的文字块之外,但仍然是列表项 #2 的一部分。我能想到的唯一解决方法是:

1. Item 1 (not literal)
2. Item 2:

    ::

        MyCode.example()

    Description of the code shown above (not literal)
Run Code Online (Sandbox Code Playgroud)

这允许非文字文本返回到先前的缩进级别,使所有内容看起来都像我想要的那样。但是,我希望将其放在::列表项的第一行。

::是否可以以允许保留在列表项的第一行的方式显式结束文字块?

python restructuredtext python-sphinx

2
推荐指数
1
解决办法
903
查看次数

标签 统计

python-sphinx ×2

restructuredtext ×2

python ×1