diff options
Diffstat (limited to 'megapixels/app')
| -rw-r--r-- | megapixels/app/site/parser.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/megapixels/app/site/parser.py b/megapixels/app/site/parser.py index ca6ac77b..44186be6 100644 --- a/megapixels/app/site/parser.py +++ b/megapixels/app/site/parser.py @@ -73,7 +73,8 @@ def format_applet(section, s3_path): if command == 'load file': if opt[0] != '/': applet['opt'] = s3_path + opt - applet['fields'] = payload[1] + if len(payload) > 1: + applet['fields'] = payload[1] return "<section><div class='applet' data-payload='{}'></div></section>".format(json.dumps(applet)) def parse_markdown(sections, s3_path, skip_h1=False): @@ -85,14 +86,14 @@ def parse_markdown(sections, s3_path, skip_h1=False): for section in sections: if skip_h1 and section.startswith('# '): continue - elif section.startswith('```'): + elif section.strip().startswith('```'): groups.append(format_section(current_group, s3_path)) current_group = [] current_group.append(section) - if section.endswith('```'): + if section.strip().endswith('```'): groups.append(format_applet("\n\n".join(current_group), s3_path)) current_group = [] - elif section.endswith('```'): + elif section.strip().endswith('```'): current_group.append(section) groups.append(format_applet("\n\n".join(current_group), s3_path)) current_group = [] |
