Sphinx代码块在HTML中奇怪地呈现

时间:2019-01-02 19:07:23

标签: python-sphinx restructuredtext

我正在尝试使用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代码块?

1 个答案:

答案 0 :(得分:1)