Sphinx 代码块在 HTML 中呈现奇怪
Sphinx code block renders strangely in HTML
我正在尝试使用 Sphinx 代码块,但在 HTML 中出现奇怪的渲染。我的来源是:
The following image shows both the source code used and how it was rendered in HTML
这是页面的第一个来源
************
Testing Page
************
Used for testing Sphinx constructs
Why does the role get rendered in HTML?
..code-block:: python
This is a code line
and so is this.
It is very confused because it emits the following error::
D:\Shared\WiseOldbird\Projects\Platform IndependentApplicationController\docs\source\Test.rst:12: WARNING: Block quote ends without a blank line; unexpected unindent
If I try it like this without the language specification it renders the role and displays the code block correctly -
note that it strips a single colon from the role directive
..code-block::
This is a code line
and so is this.
If I use a literal block.::
I get a colon in the text that introduces the literal block
Heading
-------
我需要做什么才能正确使用 Sphinx 代码块?
code-block
中缺少一个 space。
将 ..code-block:: python
更改为 .. code-block:: python
。
code-block
指令必须有一个指定语言的参数。
见http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block。
A space 在文字块之前的段落中的冒号之前也丢失了。
将 literal block.::
更改为 literal block. ::
以删除呈现文本中的冒号。
我正在尝试使用 Sphinx 代码块,但在 HTML 中出现奇怪的渲染。我的来源是:
The following image shows both the source code used and how it was rendered in HTML
这是页面的第一个来源
************
Testing Page
************
Used for testing Sphinx constructs
Why does the role get rendered in HTML?
..code-block:: python
This is a code line
and so is this.
It is very confused because it emits the following error::
D:\Shared\WiseOldbird\Projects\Platform IndependentApplicationController\docs\source\Test.rst:12: WARNING: Block quote ends without a blank line; unexpected unindent
If I try it like this without the language specification it renders the role and displays the code block correctly -
note that it strips a single colon from the role directive
..code-block::
This is a code line
and so is this.
If I use a literal block.::
I get a colon in the text that introduces the literal block
Heading
-------
我需要做什么才能正确使用 Sphinx 代码块?
code-block
中缺少一个 space。将
..code-block:: python
更改为.. code-block:: python
。code-block
指令必须有一个指定语言的参数。见http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html#directive-code-block。
A space 在文字块之前的段落中的冒号之前也丢失了。
将
literal block.::
更改为literal block. ::
以删除呈现文本中的冒号。