gemtext: fix issue with preformatted blocks
This commit is contained in:
parent
1fddf4c2b2
commit
6b0a622017
|
@ -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)
|
||||
|
|
|
@ -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,9 +108,6 @@ def parse_gemtext(text: str) -> ParsedGemtext:
|
|||
elements.append(ListItem(text))
|
||||
continue
|
||||
|
||||
if preformatted:
|
||||
preformatted.lines.append(line)
|
||||
else:
|
||||
elements.append(Paragraph(line))
|
||||
|
||||
# If a preformatted block is not closed before the file ends, consider it
|
||||
|
|
Reference in a new issue