Handle preformatted content.

This commit is contained in:
Solderpunk 2020-03-07 21:11:49 +01:00
parent 6c017f3b96
commit 7f89b94f25
1 changed files with 6 additions and 1 deletions

View File

@ -475,12 +475,17 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
def _handle_index(self, body, menu_gi):
self.index = []
preformatted = False
if self.idx_filename:
os.unlink(self.idx_filename)
tmpf = tempfile.NamedTemporaryFile("w", encoding="UTF-8", delete=False)
self.idx_filename = tmpf.name
for line in body.splitlines():
if line.startswith("=>"):
if line.startswith("```"):
preformatted = not preformatted
elif preformatted:
tmpf.write(line + "\n")
elif line.startswith("=>"):
try:
gi = GeminiItem.from_map_line(line, menu_gi)
self.index.append(gi)