From 0c786087eadbc632e21ee696b3e4bfa9284c186b Mon Sep 17 00:00:00 2001 From: dece Date: Sun, 14 Mar 2021 00:05:34 +0100 Subject: [PATCH] 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. --- bebop/gemtext.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bebop/gemtext.py b/bebop/gemtext.py index 2271238..6779de1 100644 --- a/bebop/gemtext.py +++ b/bebop/gemtext.py @@ -94,4 +94,9 @@ def parse_gemtext(text: str): else: 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