Блок кода Sphinx отображает странно в HTML - PullRequest
0 голосов
/ 02 января 2019

Я пытаюсь использовать блоки кода Sphinx и получаю странный рендеринг в HTML. Мой источник:

На следующем рисунке показан используемый исходный код и способ его отображения в 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 голосов
/ 02 января 2019
  • В code-block отсутствует пробел.

    Изменить ..code-block:: python на .. code-block:: python.

  • Директива code-block должна иметь аргумент, определяющий язык.

    См. http://www.sphinx -doc.org / ru / stable / use / restructuredtext / directives.html # directive-code-block .

  • Пробел также отсутствует перед двоеточиями в абзаце перед буквенным блоком.

    Измените literal block.:: на literal block. ::, чтобы удалить двоеточие в отображаемом тексте.

...