summaryrefslogtreecommitdiff
path: root/megapixels/app/site/parser.py
diff options
context:
space:
mode:
authorjules@lens <julescarbon@gmail.com>2019-04-18 16:55:14 +0200
committerjules@lens <julescarbon@gmail.com>2019-04-18 16:55:14 +0200
commit2e4daed06264f3dc3bbabd8fa4fc0d8ceed4c5af (patch)
tree1a17bb4459776ac91f7006a2a407ca12edd3471e /megapixels/app/site/parser.py
parent3d32e5b4ddbfbfe5d4abeda57ff200adf1532f4c (diff)
parentf8012f88641b0bb378ba79393f277c8918ebe452 (diff)
Merge branch 'master' of asdf.us:megapixels_dev
Diffstat (limited to 'megapixels/app/site/parser.py')
-rw-r--r--megapixels/app/site/parser.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/megapixels/app/site/parser.py b/megapixels/app/site/parser.py
index dc2a09f2..92d950f8 100644
--- a/megapixels/app/site/parser.py
+++ b/megapixels/app/site/parser.py
@@ -59,10 +59,13 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False):
if 'sidebar' not in section.lower():
current_group.append(section)
in_stats = True
+ if 'end sidebar' in section.lower():
+ current_group = [format_section(current_group, s3_path, 'right-sidebar', tag='div')]
+ in_stats = False
elif in_stats and not section.strip().startswith('## ') and 'end sidebar' not in section.lower():
current_group.append(section)
elif in_stats and section.strip().startswith('## ') or 'end sidebar' in section.lower():
- current_group = [format_section(current_group, s3_path, 'left-sidebar', tag='div')]
+ current_group = [format_section(current_group, s3_path, 'right-sidebar', tag='div')]
if 'end sidebar' not in section.lower():
current_group.append(section)
in_stats = False
@@ -145,8 +148,11 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False):
return '<a class="footnote_shim" name="{}_{}"> </a><a href="#{}" class="footnote" title="Footnote {}">{}</a>'.format(key, footnote_count, key, index, index)
key_regex = re.compile(key.replace('[', '\\[').replace('^', '\\^').replace(']', '\\]'))
content = key_regex.sub(footnote_tag, content)
- footnote_txt = footnote_txt.replace("{}_BACKLINKS".format(index), "".join(footnote_backlinks))
+ footnote_txt = footnote_txt.replace("{}_BACKLINKS".format(key), "".join(footnote_backlinks))
+ content += '<section>'
+ content += '<h3>References</h3>'
content += footnote_txt
+ content += '</section>'
return content
@@ -254,7 +260,8 @@ def format_footnotes(footnotes, s3_path):
continue
key, note = footnote.split(': ', 1)
footnote_index_lookup[key] = index
- footnote_list.append('<a name="{}" class="footnote_shim"></a><span class="backlinks">{}_BACKLINKS</span>'.format(key, index) + markdown(note))
+ note_markup = markdown(note).replace('<p>', '', 1).replace('</p>', '', 1)
+ footnote_list.append('{} <a name="{}" class="footnote_shim"></a><span class="backlinks">{}_BACKLINKS</span>'.format(index, key, key) + note_markup)
index += 1
footnote_txt = '<section><ul class="footnotes"><li>' + '</li><li>'.join(footnote_list) + '</li></ul></section>'