summaryrefslogtreecommitdiff
path: root/panfry
diff options
context:
space:
mode:
authorScott Bahling <sbahling@suse.de>2013-09-23 15:35:50 +0200
committerScott Bahling <sbahling@suse.de>2013-09-23 15:35:50 +0200
commitef2744a43f22563d50af678777ae1e3d8120c9a7 (patch)
treec465abeecc45a5b1fb37d955e7ddf09aa8a71835 /panfry
parenta3065a8582c97035b5f5c0c0545d1836757a5b58 (diff)
downloadpanfry-ef2744a43f22563d50af678777ae1e3d8120c9a7.tar.gz
panfry-ef2744a43f22563d50af678777ae1e3d8120c9a7.tar.xz
panfry-ef2744a43f22563d50af678777ae1e3d8120c9a7.zip
Ignore fenced code blocks when looking for headings
Diffstat (limited to 'panfry')
-rwxr-xr-xpanfry/page.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/panfry/page.py b/panfry/page.py
index efd3561..b3bd78c 100755
--- a/panfry/page.py
+++ b/panfry/page.py
@@ -85,7 +85,18 @@ class Page(TextFile):
'''
toc = []
heading = ''
+ code = 0
for line in self.markdown.split('\n'):
+ # Ignore if we are inside fenced code block
+ if line.startswith('~~~') or line.startswith('```'):
+ if not code:
+ ### FIXME. Need better way to get length of ~~
+ ### or `` characters.
+ code = len(line.strip())
+ elif len(line.strip()) >= code:
+ code = 0
+ if code:
+ continue
line = line.strip()
if heading and re.match('[=]{2}', line):
toc.append(TOCItem(heading, 1, self.htmlfile))