]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Fix edge case with single item loose lists (fixes #174)
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Wed, 2 Oct 2019 17:36:28 +0000 (13:36 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Wed, 2 Oct 2019 17:36:28 +0000 (13:36 -0400)
Sources/libMultiMarkdown/mmd.c
tests/MMD6Tests/Basic Lists.fodt
tests/MMD6Tests/Basic Lists.html
tests/MMD6Tests/Basic Lists.htmlc
tests/MMD6Tests/Basic Lists.opml
tests/MMD6Tests/Basic Lists.tex
tests/MMD6Tests/Basic Lists.text

index e33480ee8815cdee2d03238b094e30659d8b161e..20e18d372979f17705753169df89788af811d31c 100644 (file)
@@ -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) {
index 7f5029520cf081f5029cf1e272c34f5867077524..7375bde128b6d046f3cce75a9190a697248833d3 100644 (file)
@@ -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>
index 0fd925dfea703ac37e746296a7eb3bcb6c5a77a7..2694decc8b3abd564e77c287261985a4f20a8718 100644 (file)
@@ -81,6 +81,34 @@ bar</li>
 
 <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>
 
index 0d8bb937a3f5a3a317fde68a4c422b69853f8b1c..b13c95ac768fd6dc6a275c4d62a5576e75cc5e2f 100644 (file)
@@ -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>
\ No newline at end of file
index aa7d6c3f8641b776fe8010af1849a85743523860..7502d4947ca67bf800891d42684a8ee60166113b 100644 (file)
@@ -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"/>
index 68ead9dc79430d33dd8b5efc91b2110bcde8124e..b178b09cfce85305e89e1bceeb24a05e9b4e751d 100644 (file)
@@ -104,5 +104,37 @@ bar
 
 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}
index c8dc0c3ef20253cd06f23b64f36b697b7eac66fc..79206b5eea1189bcca72850a12f72412d7a7bb68 100644 (file)
@@ -65,3 +65,23 @@ bar
        bar
 
 15
+
+* foo
+
+       bar
+
+bar
+
+1. foo
+
+       bar
+
+bar
+
+* foo
+
+bar
+
+1. foo
+
+bar