Handle nested lists without explicit whitespacing
Committed 72adfd
--- a/web/markdown/__init__.py
+++ b/web/markdown/__init__.py
self.html = output
def process_blocks(self, parent, mahna):
+ def fix_list_prefixes(matchobj):
+ indent = matchobj.group(0)[2:].index("-")
+ return (("\n" + (" " * indent)) * 2) + "- "
+
+ def fix_list_suffixes(matchobj):
+ indent = matchobj.group(0)[1:].index("-")
+ return matchobj.group(0)[:-1] + (" " * indent) + "\n"
+
+ mahna = re.sub(r"\n{2,}\s+- ", fix_list_prefixes, mahna)
+ mahna = re.sub(r"(\s+- ).+\n{2,}", fix_list_suffixes, mahna)
+
for chunk in re.split(r"\n{2,}", mahna):
reference_match = reference_pattern.match(chunk)
if reference_match: