From 4a3dfa8b2c45b339b5dc8db868fd1f9abcb6f14e Mon Sep 17 00:00:00 2001 From: Scott Bahling Date: Sat, 23 Mar 2013 18:30:40 +0100 Subject: Make sure we parse markdown Cache markdown after first call. --- panfry/page.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'panfry') diff --git a/panfry/page.py b/panfry/page.py index 42eda1e..7326240 100755 --- a/panfry/page.py +++ b/panfry/page.py @@ -56,10 +56,13 @@ class Page(TextFile): TextFile.__init__(self, filename, source) self.doc = pandoc.Document() self.doc._input(self.source, format=format) + self._markdown = '' @property def markdown(self): - return self.doc.markdown + if not self._markdown: + self._markdown = self.doc.markdown + return self._markdown @property def title(self): @@ -97,7 +100,8 @@ class Page(TextFile): ''' toc = [] heading = '' - for line in self.lines: + for line in self.markdown.split('\n'): + line = line.strip() if heading and re.match('[=]{2}', line): toc.append(TOCItem(heading, 1)) continue -- cgit v1.2.3