Skip to content

Commit

Permalink
FIXED: Fix edge case with single item loose lists (fixes #174)
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcher committed Oct 2, 2019
1 parent e0f922d commit 56eb382
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 4 deletions.
27 changes: 24 additions & 3 deletions Sources/libMultiMarkdown/mmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1796,16 +1796,37 @@ void is_list_loose(token * list) {
return;
}

while (walker->next != NULL) {
if (walker->next == NULL) {
// Single item list
if (walker->type == BLOCK_LIST_ITEM) {
if (walker->child->type == BLOCK_PARA) {
loose = true;
walker = walker->child;

while (walker->next != NULL) {
if (walker->type == BLOCK_EMPTY) {
if (walker->next->type == BLOCK_PARA) {
loose = true;
}
}

walker = walker->next;
}
} else {
walker->type = BLOCK_LIST_ITEM_TIGHT;
}
}
} else {
while (walker->next != NULL) {
if (walker->type == BLOCK_LIST_ITEM) {
if (walker->child->type == BLOCK_PARA) {
loose = true;
} else {
walker->type = BLOCK_LIST_ITEM_TIGHT;
}
}

walker = walker->next;
walker = walker->next;
}
}

if (loose) {
Expand Down
36 changes: 36 additions & 0 deletions tests/MMD6Tests/Basic Lists.fodt
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,42 @@ bar</text:p></text:list-item>
</text:list>

<text:p text:style-name="Standard">15</text:p>

<text:list text:style-name="L1">
<text:list-item>
<text:p text:style-name="Standard">foo</text:p>

<text:p text:style-name="Standard">bar</text:p></text:list-item>

</text:list>

<text:p text:style-name="Standard">bar</text:p>

<text:list text:style-name="L2">
<text:list-item>
<text:p text:style-name="Standard">foo</text:p>

<text:p text:style-name="Standard">bar</text:p></text:list-item>

</text:list>

<text:p text:style-name="Standard">bar</text:p>

<text:list text:style-name="L1">
<text:list-item>
<text:p text:style-name="Standard">foo</text:p></text:list-item>

</text:list>

<text:p text:style-name="Standard">bar</text:p>

<text:list text:style-name="L2">
<text:list-item>
<text:p text:style-name="Standard">foo</text:p></text:list-item>

</text:list>

<text:p text:style-name="Standard">bar</text:p>
</office:text>
</office:body>
</office:document>
28 changes: 28 additions & 0 deletions tests/MMD6Tests/Basic Lists.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,34 @@

<p>15</p>

<ul>
<li><p>foo</p>

<p>bar</p></li>
</ul>

<p>bar</p>

<ol>
<li><p>foo</p>

<p>bar</p></li>
</ol>

<p>bar</p>

<ul>
<li>foo</li>
</ul>

<p>bar</p>

<ol>
<li>foo</li>
</ol>

<p>bar</p>

</body>
</html>

28 changes: 28 additions & 0 deletions tests/MMD6Tests/Basic Lists.htmlc
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,31 @@ bar</li>
</ul>

<p>15</p>

<ul>
<li><p>foo</p>

<p>bar</p></li>
</ul>

<p>bar</p>

<ol>
<li><p>foo</p>

<p>bar</p></li>
</ol>

<p>bar</p>

<ul>
<li>foo</li>
</ul>

<p>bar</p>

<ol>
<li>foo</li>
</ol>

<p>bar</p>
2 changes: 1 addition & 1 deletion tests/MMD6Tests/Basic Lists.opml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<opml version="1.0">
<head><title>Basic Lists</title></head>
<body>
<outline text="&gt;&gt;Preamble&lt;&lt;" _note="&#10;* foo&#10;* foo&#10;* foo&#10;&#10;&#10;bar&#10;&#10;* foo&#10;&#10;* foo&#10;&#10;* foo&#10;&#10;&#10;bar&#10;&#10;* foo&#10;* foo&#10;&#10;*&#9;&#9;foo&#10;&#10;5&#10;&#10;1. foo&#10;2. foo&#10;3.&#9;foo&#10;&#10;bar&#10;&#10;1. foo&#10;&#10;2. foo&#10;&#10;3. foo&#10;&#10;bar&#10;&#10;1. foo&#10;2. foo&#10;&#10;3. foo&#10;&#10;10&#10;&#10;+ foo&#10;+ foo&#10;+ foo&#10;&#10;bar&#10;&#10;- foo&#10;- foo&#10;- foo&#10;&#10;bar&#10;&#10;* foo&#10;&#9;bar&#10;* foo&#10;&#9;bar&#10;* foo&#10;&#9;bar&#10;&#10;15&#10;"></outline>
<outline text="&gt;&gt;Preamble&lt;&lt;" _note="&#10;* foo&#10;* foo&#10;* foo&#10;&#10;&#10;bar&#10;&#10;* foo&#10;&#10;* foo&#10;&#10;* foo&#10;&#10;&#10;bar&#10;&#10;* foo&#10;* foo&#10;&#10;*&#9;&#9;foo&#10;&#10;5&#10;&#10;1. foo&#10;2. foo&#10;3.&#9;foo&#10;&#10;bar&#10;&#10;1. foo&#10;&#10;2. foo&#10;&#10;3. foo&#10;&#10;bar&#10;&#10;1. foo&#10;2. foo&#10;&#10;3. foo&#10;&#10;10&#10;&#10;+ foo&#10;+ foo&#10;+ foo&#10;&#10;bar&#10;&#10;- foo&#10;- foo&#10;- foo&#10;&#10;bar&#10;&#10;* foo&#10;&#9;bar&#10;* foo&#10;&#9;bar&#10;* foo&#10;&#9;bar&#10;&#10;15&#10;&#10;* foo&#10;&#10;&#9;bar&#10;&#10;bar&#10;&#10;1. foo&#10;&#10;&#9;bar&#10;&#10;bar&#10;&#10;* foo&#10;&#10;bar&#10;&#10;1. foo&#10;&#10;bar&#10;"></outline>
<outline text="&gt;&gt;Metadata&lt;&lt;">
<outline text="title" _note="Basic Lists"/>
<outline text="latexconfig" _note="article"/>
Expand Down
32 changes: 32 additions & 0 deletions tests/MMD6Tests/Basic Lists.tex
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,37 @@

15

\begin{itemize}
\item foo

bar

\end{itemize}

bar

\begin{enumerate}
\item foo

bar

\end{enumerate}

bar

\begin{itemize}
\item foo

\end{itemize}

bar

\begin{enumerate}
\item foo

\end{enumerate}

bar

\input{mmd6-article-footer}
\end{document}
20 changes: 20 additions & 0 deletions tests/MMD6Tests/Basic Lists.text
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,23 @@ bar
bar

15

* foo

bar

bar

1. foo

bar

bar

* foo

bar

1. foo

bar

0 comments on commit 56eb382

Please sign in to comment.