Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing cuddled-lists with a single list item #288

Merged
merged 2 commits into from Apr 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/markdown2.py
Expand Up @@ -2056,8 +2056,13 @@ def _form_paragraphs(self, text):
# text (issue 33). Note the `[-1]` is a quick way to
# consider numeric bullets (e.g. "1." and "2.") to be
# equal.
if (li and len(li.group(2)) <= 3 and li.group("next_marker")
and li.group("marker")[-1] == li.group("next_marker")[-1]):
if (li and len(li.group(2)) <= 3
and (
(li.group("next_marker") and li.group("marker")[-1] == li.group("next_marker")[-1])
or
li.group("next_marker") is None
)
):
start = li.start()
cuddled_list = self._do_lists(graf[start:]).rstrip("\n")
assert cuddled_list.startswith("<ul>") or cuddled_list.startswith("<ol>")
Expand Down
22 changes: 20 additions & 2 deletions test/tm-cases/cuddled_para_and_list.html
Expand Up @@ -24,9 +24,27 @@
</ol>

<p>Here is an asterisk,
* What do you think
* What do you think
about it?</p>

<p>I suggest using version
8. Oops, now this line is treated
8. Oops, now this line is treated
as a sub-list.</p>

<p>List with single item:</p>

<ul>
<li>bullet1</li>
</ul>

<p>Another list with single item:</p>

<ul>
<li>bullet1</li>
</ul>

<p>Yet, another list with single item:</p>

<ul>
<li>bullet1</li>
</ul>
12 changes: 10 additions & 2 deletions test/tm-cases/cuddled_para_and_list.text
Expand Up @@ -15,10 +15,18 @@ And these in order:
3. bullet3

Here is an asterisk,
* What do you think
* What do you think
about it?

I suggest using version
8. Oops, now this line is treated
8. Oops, now this line is treated
as a sub-list.

List with single item:
* bullet1

Another list with single item:
* bullet1

Yet, another list with single item:
* bullet1