diff options
Diffstat (limited to 'megapixels/app/site/parser.py')
| -rw-r--r-- | megapixels/app/site/parser.py | 13 |
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>' |
