首页 > 解决方案 > Sphinx中普通文本中的换行符

问题描述

我在 .rst 文件中有以下文本:

Some text.
* Heading
  | The first topic.
  | Another topic which is very verbose and spans multiple lines ad infinitum.
  Topic continued......................................

我希望它呈现为:

Some text.
* Heading
  The first topic.
  Another topic which is very verbose and spans multiple lines ad infinitum....................
  Topic continued.............

但是它在 Html 中呈现如下:

Some text.
* Heading| The first topic.| Another topic which is very verbose and spans multiple lines ad infinitum .................... Topic continued

Sphinx 文档建议使用该|符号来表示换行符,就像 Stackoverflow 上的几篇帖子一样,但我一直无法让它工作。我想要一种独立于使用的 Sphinx 构建器的方法。

元素之间的空行确实有效,但没有给出我想要的视觉效果。

我需要做什么?

标签: python-sphinx

解决方案


分两步执行此操作。

首先让您的 reStructuredText 使用正确的空格来生成一个可用的 HTML 结构,并应用默认的视觉样式。

Some text.

* Heading

  | The first topic.
  | Another topic which is very verbose and spans multiple lines ad infinitum.

  Topic continued......................................

第二次覆盖默认样式表以生成所需的视觉效果,如本文所述,如何为 reStructuredText、Sphinx、ReadTheDocs 等设置自定义样式?.


推荐阅读