commit 7f89b94f2563ec2d608da2c56e4732a620748416
parent 6c017f3b9603c4f6a0552a9f9a3c7a018c3d1010
Author: Solderpunk <solderpunk@sdf.org>
Date: Sat, 7 Mar 2020 21:11:49 +0100
Handle preformatted content.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/av98.py b/av98.py
@@ -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)