diff --git a/BOARD.txt b/BOARD.txt index 00fb7f7..930018c 100644 --- a/BOARD.txt +++ b/BOARD.txt @@ -30,3 +30,4 @@ buffers (tabs) handle soft-hyphens on wrapping bug: combining chars reduce lengths non shit command-line +response code 11 (if still there) diff --git a/bebop/gemtext.py b/bebop/gemtext.py index 330cd65..1fac047 100644 --- a/bebop/gemtext.py +++ b/bebop/gemtext.py @@ -66,6 +66,18 @@ def parse_gemtext(text: str) -> ParsedGemtext: if not line: continue + if line.startswith(Preformatted.FENCE): + if preformatted: + elements.append(preformatted) + preformatted = None + else: + preformatted = Preformatted([]) + continue + + if preformatted: + preformatted.lines.append(line) + continue + match = Title.RE.match(line) if match: hashtags, text = match.groups() @@ -84,14 +96,6 @@ def parse_gemtext(text: str) -> ParsedGemtext: elements.append(Link(url, text, last_link_id)) continue - if line.startswith(Preformatted.FENCE): - if preformatted: - elements.append(preformatted) - preformatted = None - else: - preformatted = Preformatted([]) - continue - match = Blockquote.RE.match(line) if match: text = match.groups()[0] @@ -104,10 +108,7 @@ def parse_gemtext(text: str) -> ParsedGemtext: elements.append(ListItem(text)) continue - if preformatted: - preformatted.lines.append(line) - 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.