Hi,
I'm debugging an strange behaviour of docutils 0.18.1 with Python 3.8.10.
Minimal reproducible example:
from docutils.core import publish_parts from docutils.writers.html4css1 import Writer content = """Some text :012345678901234: foo :a: b :0123456789012345: bar :01234567890123: baz """ print(publish_parts(content, writer=Writer())["fragment"])
Output:
<p>Some text</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field"><th class="field-name" colspan="2">012345678901234:</th></tr> <tr class="field"><td> </td><td class="field-body">foo</td> </tr> <tr class="field"><th class="field-name">a:</th><td class="field-body">b</td> </tr> <tr class="field"><th class="field-name" colspan="2">0123456789012345:</th></tr> <tr class="field"><td> </td><td class="field-body">bar</td> </tr> <tr class="field"><th class="field-name">01234567890123:</th><td class="field-body">baz</td> </tr> </tbody> </table>
It seems that doesn't accept field names larger than 14 characters, adding additionals rows in the table with HTML escaped
spaces. Checking the documentation about field lists I can't find anything related, nor in the RFC822.
Is this an expected behaviour? Thanks!
There is no limit to the length of field names (check the output of the "pseudoxml" or "docutils XML" writers).
The observed behaviour is a rendering feature of the "html4css1" writer, described in the Docutils Configuration guide. You can configure the field-name limit or consider switching to the html5 writer that converts field lists to HTML description lists with the "field-list" class.
Great, thank you!