Inconsistent line spacing in RestructuredText document

倖福魔咒の 提交于 2019-12-11 01:14:39

问题


I'm build RST files for my company's documentation. One irritating thing is that enumerated lists don't seem to have any consistency in terms of line spacing.

Is there a simple way to solve this?

Robert


回答1:


It's a well known problem of docutils, the library on which Sphinx is built.

From Sphinx issue tracker on GitHub:

tk0miya wrote:
In my short investigation:

The behavior comes from docutils (base library of Sphinx). In docutils.writers.html4css1.HTMLTranslator, docutils generates <p> tag if list includes any items excepting paragraphs and nested lists.

To fix this, set self.compact_simple in visit_list_item instead of visit_bullet_list and visit_enumerated_list. But we have to know why docutils check whole of list.

Source: Spinx-Doc/Sphinx #2258 - Nested field lists inside list items cause unwanted space in HTML output


See related issues:

  • https://github.com/rtfd/sphinx_rtd_theme/issues/119



回答2:


I'm unsure how to apply Paebbels answer, however I was able to get rid of the <p> tags by changing to the html4 writer by adding this line to my conf.py.

html4_writer = true

This obviously changes it to the html4 writer, so you'll need to determine whether this is acceptable or not.



来源:https://stackoverflow.com/questions/49700502/inconsistent-line-spacing-in-restructuredtext-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!