Stack overflows can occur when parjing Jira lists (#39)
diff --git a/migration/src/markup/lists.py b/migration/src/markup/lists.py
index 47853a2..3ce03ca 100644
--- a/migration/src/markup/lists.py
+++ b/migration/src/markup/lists.py
@@ -40,6 +40,11 @@
for line in tokens:
# print(repr(line))
+ if line == "\n":
+ # can't really explain but if this is the first item, an empty string should be added to preserve line feed
+ if len(result) == 0:
+ result.append("")
+ continue
bullets, text = line.split(" ", maxsplit=1)
nested_indent = 0
@@ -66,12 +71,11 @@
NL = LineEnd()
LIST_BREAK = NL + Optional(White(" \t")) + NL | StringEnd()
IGNORE = BlockQuote(**self.init_kwargs).expr | Panel(**self.init_kwargs).expr | Color(**self.init_kwargs).expr
- ROW = Optional(LineStart()) + Combine(
- Optional(White(" \t"))
+ ROW = (LineStart() ^ LineEnd()) + Combine(
+ Optional(NL)
+ Optional(self.nested_token, default="")
+ ListIndent(self.indent_state, self.tokens)
+ SkipTo(NL + Optional(White(" \t")) + Char(self.nested_token + self.tokens) | LIST_BREAK, ignore=IGNORE)
- + Optional(NL),
)
return OneOrMore(ROW, stopOn=LIST_BREAK).setParseAction(self.action)