From 7f718f499d535daa6a69d4004195618ac030ad24 Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Mon, 11 Jan 2021 15:47:51 +0100 Subject: [PATCH] Work around marko issue with rendering files not-newline-terminated. --- app/db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/db.py b/app/db.py index 6489e19..ad482de 100644 --- a/app/db.py +++ b/app/db.py @@ -207,6 +207,9 @@ class Subnode: if self.mediatype == 'text/plain': with open(path) as f: self.content = f.read() + # Marko raises IndexError on render if the file doesn't terminate with a newline. + if not self.content.endswith('\n'): + self.content = self.content + '\n' self.forward_links = content_to_forward_links(self.content) elif self.mediatype.startswith('image'): with open(path, 'rb') as f: