【问题标题】:Sphinx code block renders strangely in HTMLSphinx 代码块在 HTML 中奇怪地呈现
【发布时间】:2019-01-02 19:07:22
【问题描述】:

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

【问题讨论】:

  • 请将代码和标记显示为文本,而不是图像。
  • 我不知道如何在 Stackoverflow 上将标记显示为文本
  • 我正在尝试显示呈现的 HTML 输出。
  • 是的,没关系。但请以纯文本形式提供 RST 标记。
  • 缺少一个空格。将..code-block:: python 更改为.. code-block:: python

标签: python-sphinx restructuredtext


【解决方案1】:

【讨论】:

  • 我将添加一个空行应该在.. code-block:: python 和实际代码之间(我有这个错误并最终出现在这里,所以我添加了我的问题)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多