问题
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). Indocutils.writers.html4css1.HTMLTranslator,docutilsgenerates<p>tag if list includes any items excepting paragraphs and nested lists.To fix this, set
self.compact_simpleinvisit_list_iteminstead ofvisit_bullet_listandvisit_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