gemtext: auto-close preformatted blocks

The spec does not say if preformatted text should be rendered or not if
the file stops before the closing fence is found. The wording makes me
think it is more adequate to auto-close the block in this case.
This commit is contained in:
dece 2021-03-14 00:05:34 +01:00
parent fef350804c
commit 0c786087ea

View file

@ -94,4 +94,9 @@ def parse_gemtext(text: str):
else: else:
elements.append(Paragraph(line)) elements.append(Paragraph(line))
# If a preformatted block is not closed before the file ends, consider it
# closed anyway; the spec does not seem to talk about that case.
if preformatted:
elements.append(preformatted)
return elements return elements