diff options
Diffstat (limited to 'megapixels/app/site/parser.py')
| -rw-r--r-- | megapixels/app/site/parser.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/megapixels/app/site/parser.py b/megapixels/app/site/parser.py index 00470e4b..dc2a09f2 100644 --- a/megapixels/app/site/parser.py +++ b/megapixels/app/site/parser.py @@ -27,6 +27,7 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False): current_group = [] footnotes = [] in_stats = False + in_columns = False in_footnotes = False ignoring = False @@ -50,10 +51,11 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False): footnotes.append(section) elif ignoring: continue + elif '### statistics' in section.lower() or '### sidebar' in section.lower(): if len(current_group): groups.append(format_section(current_group, s3_path)) - current_group = [] + current_group = [format_include("{% include 'sidebar.html' %}", metadata)] if 'sidebar' not in section.lower(): current_group.append(section) in_stats = True @@ -64,6 +66,26 @@ def parse_markdown(metadata, sections, s3_path, skip_h1=False): if 'end sidebar' not in section.lower(): current_group.append(section) in_stats = False + + elif '=== columns' in section.lower(): + if len(current_group): + groups.append(format_section(current_group, s3_path)) + current_group = [] + in_columns = True + column_partz = section.split(' ') + if len(column_partz) == 3: + column_count = column_partz[2] + else: + column_count = "N" + groups.append("<section><div class='columns columns-{}'>".format(column_count)) + elif in_columns is True and '===' in section: + groups.append(format_section(current_group, s3_path, type='column', tag='div')) + current_group = [] + if 'end columns' in section: + groups.append("</div></section>") + in_columns = False + current_group = [] + elif section.strip().startswith('{% include'): groups.append(format_section(current_group, s3_path)) current_group = [] @@ -245,15 +267,6 @@ def format_include(section, metadata): include_fn = section.strip().strip('\n').strip().strip('{%').strip().strip('%}').strip() include_fn = include_fn.strip('include').strip().strip('"').strip().strip("'").strip() return includes_env.get_template(include_fn).render(metadata=metadata) - # include_dir = cfg.DIR_SITE_INCLUDES - # try: - # includes_env.get_template(fp_html) - # with open(join(include_dir, fp_html), 'r') as fp: - # html = fp.read().replace('\n', '') - # return html - # except Exception as e: - # print(f'Error parsing include: {e}') - # return '' def format_applet(section, s3_path): """ |
