diff --git a/lib/markdown2.py b/lib/markdown2.py index 86876ab5..0ea19390 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -2181,8 +2181,13 @@ def _form_paragraphs(self, text): ): start = li.start() cuddled_list = self._do_lists(graf[start:]).rstrip("\n") - assert re.match(r'^<(?:ul|ol).*?>', cuddled_list) - graf = graf[:start] + if re.match(r'^<(?:ul|ol).*?>', cuddled_list): + graf = graf[:start] + else: + # Not quite a cuddled list. (See not_quite_a_list_cuddled_lists test case) + # Store as a simple paragraph. + graf = cuddled_list + cuddled_list = None # Wrap
tags. graf = self._run_span_gamut(graf) diff --git a/test/tm-cases/not_quite_a_list_cuddled_lists.html b/test/tm-cases/not_quite_a_list_cuddled_lists.html new file mode 100644 index 00000000..0a675da4 --- /dev/null +++ b/test/tm-cases/not_quite_a_list_cuddled_lists.html @@ -0,0 +1,26 @@ +
So:
+ +And:
+ +However, because ASCII art can have long dash/asterisk lines let ensure that:
+ +- - - - - - - This isn't a list.
+ +* * Nor is this a list. +- - - Or this.
+ +- - - - - - - - - - + + hi there ascii art +- - - - - - - - - - +
diff --git a/test/tm-cases/not_quite_a_list_cuddled_lists.opts b/test/tm-cases/not_quite_a_list_cuddled_lists.opts new file mode 100644 index 00000000..697d1301 --- /dev/null +++ b/test/tm-cases/not_quite_a_list_cuddled_lists.opts @@ -0,0 +1 @@ +{"extras": ["cuddled-lists"]} \ No newline at end of file diff --git a/test/tm-cases/not_quite_a_list_cuddled_lists.text b/test/tm-cases/not_quite_a_list_cuddled_lists.text new file mode 100644 index 00000000..11793ccd --- /dev/null +++ b/test/tm-cases/not_quite_a_list_cuddled_lists.text @@ -0,0 +1,21 @@ +So: +- This +- is +- a list. + +And: +* *This* is +* a list +* too. + +However, because ASCII art can have long dash/asterisk lines let ensure that: + +- - - - - - - This isn't a list. + +* * Nor is this a list. +- - - Or this. + + +- - - - - - - - - - + + hi there ascii art +- - - - - - - - - - +