summaryrefslogtreecommitdiff
path: root/megapixels
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-12-16 12:42:21 +0100
committerJules Laplace <julescarbon@gmail.com>2018-12-16 12:42:21 +0100
commit9ec276ec3ddbbaad554657333453317947f98d63 (patch)
treee24d04e37ef8020776d41f4037ddbe58ea378489 /megapixels
parent5e6ab885e94c1d3118bac1ea3a575d12a3d1434c (diff)
generate single page with -i
Diffstat (limited to 'megapixels')
-rw-r--r--megapixels/app/site/parser.py9
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 = []