aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-02-23 15:40:06 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-02-25 17:33:54 -0800
commitba05e1ea02d5227796f12dea2404285300021de6 (patch)
tree6ee0d7372dcfcd55c67c52b590b32cb1c12701f0
parent38c028bd50fc3781e69370864f163f8d33fd481f (diff)
downloadpandoc-ba05e1ea02d5227796f12dea2404285300021de6.tar.gz
Shared.compactify: Avoid mixed lists.
This improves on the original fix to #5285 by preventing other mixed lists (lists with a mix of Plain and Para elements) that were allowed given the original fix.
-rw-r--r--src/Text/Pandoc/Shared.hs13
-rw-r--r--test/command/5285.md17
-rw-r--r--test/rst-reader.native10
-rw-r--r--test/rst-reader.rst2
-rw-r--r--test/testsuite.native2
-rw-r--r--test/writer.custom2
-rw-r--r--test/writer.dokuwiki2
-rw-r--r--test/writer.fb21
-rw-r--r--test/writer.haddock1
-rw-r--r--test/writer.html42
-rw-r--r--test/writer.html52
-rw-r--r--test/writer.icml4
-rw-r--r--test/writer.markdown1
-rw-r--r--test/writer.mediawiki2
-rw-r--r--test/writer.native2
-rw-r--r--test/writer.opendocument1
-rw-r--r--test/writer.opml2
-rw-r--r--test/writer.org1
-rw-r--r--test/writer.plain1
-rw-r--r--test/writer.rst1
-rw-r--r--test/writer.rtf2
-rw-r--r--test/writer.texinfo1
-rw-r--r--test/writer.textile2
23 files changed, 48 insertions, 26 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index a945c9355..db00d5aa4 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -424,13 +424,12 @@ compactify [] = []
compactify items =
let (others, final) = (init items, last items)
in case reverse (B.toList final) of
- (Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
- -- if this is only Para, change to Plain
- [_] -> others ++ [B.fromList (reverse $ Plain a : xs)]
- -- if other Paras, it's a loose list, change
- -- all Plain to Para
- _ -> map (fmap plainToPara) items
- _ -> items
+ (Para a:xs)
+ | null [Para x | Para x <- (xs ++ concatMap B.toList others)]
+ -> others ++ [B.fromList (reverse (Plain a : xs))]
+ _ | null [Para x | Para x <- concatMap B.toList items]
+ -> items
+ _ -> map (fmap plainToPara) items
plainToPara :: Block -> Block
plainToPara (Plain ils) = Para ils
diff --git a/test/command/5285.md b/test/command/5285.md
index 780812761..6085ec1a9 100644
--- a/test/command/5285.md
+++ b/test/command/5285.md
@@ -13,3 +13,20 @@
,[Para [Str "a"]]
,[Para [Str "b"]]]]
```
+
+```
+% pandoc -t native
+- foo
+
+ foo
+- foo
+
+ > foo
+^D
+[BulletList
+ [[Para [Str "foo"]
+ ,Para [Str "foo"]]
+ ,[Para [Str "foo"]
+ ,BlockQuote
+ [Para [Str "foo"]]]]]
+```
diff --git a/test/rst-reader.native b/test/rst-reader.native
index cd1437ac8..70ed3cf60 100644
--- a/test/rst-reader.native
+++ b/test/rst-reader.native
@@ -96,8 +96,8 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,OrderedList (1,Decimal,Period)
[[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",SoftBreak,Str "back."]]
- ,[Plain [Str "Item",Space,Str "2."]]
- ,[Plain [Str "Item",Space,Str "3."]]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
,Para [Str "Nested:"]
,BulletList
[[Plain [Str "Tab"]
@@ -107,17 +107,17 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
[[Plain [Str "Tab"]]]]]]]
,Para [Str "Here\8217s",Space,Str "another:"]
,OrderedList (1,Decimal,Period)
- [[Plain [Str "First"]]
+ [[Para [Str "First"]]
,[Para [Str "Second:"]
,BlockQuote
[BulletList
[[Plain [Str "Fee"]]
,[Plain [Str "Fie"]]
,[Plain [Str "Foe"]]]]]
- ,[Plain [Str "Third"]]]
+ ,[Para [Str "Third"]]]
,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
,OrderedList (2,Decimal,TwoParens)
- [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ [[Para [Str "begins",Space,Str "with",Space,Str "2"]]
,[Para [Str "and",Space,Str "now",Space,Str "3"]
,Para [Str "with",Space,Str "a",Space,Str "continuation"]
,OrderedList (4,LowerRoman,Period)
diff --git a/test/rst-reader.rst b/test/rst-reader.rst
index cfe959f2d..a918c0e2c 100644
--- a/test/rst-reader.rst
+++ b/test/rst-reader.rst
@@ -192,7 +192,7 @@ Multiple paragraphs:
Item 1. graf two. The quick brown fox jumped over the lazy dog's
back.
-
+
2. Item 2.
3. Item 3.
diff --git a/test/testsuite.native b/test/testsuite.native
index 73fcc0633..f9132c797 100644
--- a/test/testsuite.native
+++ b/test/testsuite.native
@@ -137,7 +137,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
,OrderedList (2,Decimal,TwoParens)
- [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ [[Para [Str "begins",Space,Str "with",Space,Str "2"]]
,[Para [Str "and",Space,Str "now",Space,Str "3"]
,Para [Str "with",Space,Str "a",Space,Str "continuation"]
,OrderedList (4,LowerRoman,Period)
diff --git a/test/writer.custom b/test/writer.custom
index f3341360e..595d8f70e 100644
--- a/test/writer.custom
+++ b/test/writer.custom
@@ -263,7 +263,7 @@ indented with spaces</p></li>
<h2 id="fancy-list-markers">Fancy list markers</h2>
<ol>
-<li>begins with 2</li>
+<li><p>begins with 2</p></li>
<li><p>and now 3</p>
<p>with a continuation</p>
diff --git a/test/writer.dokuwiki b/test/writer.dokuwiki
index 34f4246db..5e6773799 100644
--- a/test/writer.dokuwiki
+++ b/test/writer.dokuwiki
@@ -205,7 +205,7 @@ Same thing but with paragraphs:
===== Fancy list markers =====
<HTML><ol start="2" style="list-style-type: decimal;"></HTML>
-<HTML><li></HTML>begins with 2<HTML></li></HTML>
+<HTML><li></HTML><HTML><p></HTML>begins with 2<HTML></p></HTML><HTML></li></HTML>
<HTML><li></HTML><HTML><p></HTML>and now 3<HTML></p></HTML>
<HTML><p></HTML>with a continuation<HTML></p></HTML>
<HTML><ol start="4" style="list-style-type: lower-roman;"></HTML>
diff --git a/test/writer.fb2 b/test/writer.fb2
index 6f5b1cfcd..6f8c25cde 100644
--- a/test/writer.fb2
+++ b/test/writer.fb2
@@ -302,6 +302,7 @@ indented with spaces</p>
<p>Fancy list markers</p>
</title>
<p>(2) begins with 2</p>
+<empty-line />
<p>(3) and now 3</p>
<empty-line />
<p>    with a continuation</p>
diff --git a/test/writer.haddock b/test/writer.haddock
index 13f22021d..fbe6c257b 100644
--- a/test/writer.haddock
+++ b/test/writer.haddock
@@ -236,6 +236,7 @@ Same thing but with paragraphs:
#fancy-list-markers#
(2) begins with 2
+
(3) and now 3
with a continuation
diff --git a/test/writer.html4 b/test/writer.html4
index bed6617a0..4d5d11897 100644
--- a/test/writer.html4
+++ b/test/writer.html4
@@ -196,7 +196,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{</code></pre>
</ul>
<h2 id="fancy-list-markers">Fancy list markers</h2>
<ol start="2" style="list-style-type: decimal">
-<li>begins with 2</li>
+<li><p>begins with 2</p></li>
<li><p>and now 3</p>
<p>with a continuation</p>
<ol start="4" style="list-style-type: lower-roman">
diff --git a/test/writer.html5 b/test/writer.html5
index 39b5344dd..e0b30f4af 100644
--- a/test/writer.html5
+++ b/test/writer.html5
@@ -199,7 +199,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{</code></pre>
</ul>
<h2 id="fancy-list-markers">Fancy list markers</h2>
<ol start="2" type="1">
-<li>begins with 2</li>
+<li><p>begins with 2</p></li>
<li><p>and now 3</p>
<p>with a continuation</p>
<ol start="4" type="i">
diff --git a/test/writer.icml b/test/writer.icml
index 5fdf450fb..4c1a2b950 100644
--- a/test/writer.icml
+++ b/test/writer.icml
@@ -400,7 +400,7 @@
<BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
</Properties>
</ParagraphStyle>
- <ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; beginsWith-2" Name="NumList &gt; first &gt; beginsWith-2" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; beginsWith-2 &gt; Paragraph" Name="NumList &gt; first &gt; beginsWith-2 &gt; Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
<Properties>
<BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
</Properties>
@@ -1105,7 +1105,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{</Content>
</CharacterStyleRange>
</ParagraphStyleRange>
<Br />
-<ParagraphStyleRange NumberingStartAt="2" AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; beginsWith-2" NumberingContinue="false">
+<ParagraphStyleRange NumberingStartAt="2" AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; beginsWith-2 &gt; Paragraph" NumberingContinue="false">
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
<Content>begins with 2</Content>
</CharacterStyleRange>
diff --git a/test/writer.markdown b/test/writer.markdown
index de0821970..6aab1e597 100644
--- a/test/writer.markdown
+++ b/test/writer.markdown
@@ -239,6 +239,7 @@ Fancy list markers
------------------
(2) begins with 2
+
(3) and now 3
with a continuation
diff --git a/test/writer.mediawiki b/test/writer.mediawiki
index 29686f3e7..79cc1b4e1 100644
--- a/test/writer.mediawiki
+++ b/test/writer.mediawiki
@@ -198,7 +198,7 @@ Same thing but with paragraphs:
== Fancy list markers ==
<ol start="2" style="list-style-type: decimal;">
-<li>begins with 2</li>
+<li><p>begins with 2</p></li>
<li><p>and now 3</p>
<p>with a continuation</p>
<ol start="4" style="list-style-type: lower-roman;">
diff --git a/test/writer.native b/test/writer.native
index 73fcc0633..f9132c797 100644
--- a/test/writer.native
+++ b/test/writer.native
@@ -137,7 +137,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
,OrderedList (2,Decimal,TwoParens)
- [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ [[Para [Str "begins",Space,Str "with",Space,Str "2"]]
,[Para [Str "and",Space,Str "now",Space,Str "3"]
,Para [Str "with",Space,Str "a",Space,Str "continuation"]
,OrderedList (4,LowerRoman,Period)
diff --git a/test/writer.opendocument b/test/writer.opendocument
index 625cdf2c6..2d9068d07 100644
--- a/test/writer.opendocument
+++ b/test/writer.opendocument
@@ -1115,7 +1115,6 @@
<style:style style:name="P38" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L21">
</style:style>
<style:style style:name="P39" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L22">
- <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
</style:style>
<style:style style:name="P40" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L23">
<style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
diff --git a/test/writer.opml b/test/writer.opml
index 4e67652d2..6bdcb882e 100644
--- a/test/writer.opml
+++ b/test/writer.opml
@@ -39,7 +39,7 @@
</outline>
<outline text="Tabs and spaces" _note="- this is a list item indented with tabs&#10;&#10;- this is a list item indented with spaces&#10;&#10; - this is an example list item indented with tabs&#10;&#10; - this is an example list item indented with spaces">
</outline>
- <outline text="Fancy list markers" _note="1. begins with 2&#10;2. and now 3&#10;&#10; with a continuation&#10;&#10; 1. sublist with roman numerals, starting with 4&#10; 2. more items&#10; 1. a subsublist&#10; 2. a subsublist&#10;&#10;Nesting:&#10;&#10;1. Upper Alpha&#10; 1. Upper Roman.&#10; 1. Decimal start with 6&#10; 1. Lower alpha with paren&#10;&#10;Autonumbering:&#10;&#10;1. Autonumber.&#10;2. More.&#10; 1. Nested.&#10;&#10;Should not be a list item:&#10;&#10;M.A. 2007&#10;&#10;B. Williams&#10;&#10;------------------------------------------------------------------------">
+ <outline text="Fancy list markers" _note="1. begins with 2&#10;&#10;2. and now 3&#10;&#10; with a continuation&#10;&#10; 1. sublist with roman numerals, starting with 4&#10; 2. more items&#10; 1. a subsublist&#10; 2. a subsublist&#10;&#10;Nesting:&#10;&#10;1. Upper Alpha&#10; 1. Upper Roman.&#10; 1. Decimal start with 6&#10; 1. Lower alpha with paren&#10;&#10;Autonumbering:&#10;&#10;1. Autonumber.&#10;2. More.&#10; 1. Nested.&#10;&#10;Should not be a list item:&#10;&#10;M.A. 2007&#10;&#10;B. Williams&#10;&#10;------------------------------------------------------------------------">
</outline>
</outline>
<outline text="Definition Lists" _note="Tight using spaces:&#10;&#10;apple &#10;red fruit&#10;&#10;orange &#10;orange fruit&#10;&#10;banana &#10;yellow fruit&#10;&#10;Tight using tabs:&#10;&#10;apple &#10;red fruit&#10;&#10;orange &#10;orange fruit&#10;&#10;banana &#10;yellow fruit&#10;&#10;Loose:&#10;&#10;apple &#10;red fruit&#10;&#10;orange &#10;orange fruit&#10;&#10;banana &#10;yellow fruit&#10;&#10;Multiple blocks with italics:&#10;&#10;*apple* &#10;red fruit&#10;&#10;contains seeds, crisp, pleasant to taste&#10;&#10;*orange* &#10;orange fruit&#10;&#10; { orange code block }&#10;&#10;&gt; orange block quote&#10;&#10;Multiple definitions, tight:&#10;&#10;apple &#10;red fruit&#10;&#10;computer&#10;&#10;orange &#10;orange fruit&#10;&#10;bank&#10;&#10;Multiple definitions, loose:&#10;&#10;apple &#10;red fruit&#10;&#10;computer&#10;&#10;orange &#10;orange fruit&#10;&#10;bank&#10;&#10;Blank line after term, indented marker, alternate markers:&#10;&#10;apple &#10;red fruit&#10;&#10;computer&#10;&#10;orange &#10;orange fruit&#10;&#10;1. sublist&#10;2. sublist">
diff --git a/test/writer.org b/test/writer.org
index 32fcfc404..cd2be4574 100644
--- a/test/writer.org
+++ b/test/writer.org
@@ -294,6 +294,7 @@ Same thing but with paragraphs:
:END:
2) begins with 2
+
3) and now 3
with a continuation
diff --git a/test/writer.plain b/test/writer.plain
index 031c4a3e6..79921fa27 100644
--- a/test/writer.plain
+++ b/test/writer.plain
@@ -244,6 +244,7 @@ Tabs and spaces
Fancy list markers
(2) begins with 2
+
(3) and now 3
with a continuation
diff --git a/test/writer.rst b/test/writer.rst
index b47490de2..683a41f30 100644
--- a/test/writer.rst
+++ b/test/writer.rst
@@ -261,6 +261,7 @@ Fancy list markers
------------------
(2) begins with 2
+
(3) and now 3
with a continuation
diff --git a/test/writer.rtf b/test/writer.rtf
index c67c67a83..4f3751b36 100644
--- a/test/writer.rtf
+++ b/test/writer.rtf
@@ -132,7 +132,7 @@ These should not be escaped: \\$ \\\\ \\> \\[ \\\{\par}
{\pard \ql \f0 \sa180 \li720 \fi-360 \endash \tx360\tab this is an example list item indented with tabs\par}
{\pard \ql \f0 \sa180 \li720 \fi-360 \endash \tx360\tab this is an example list item indented with spaces\sa180\sa180\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Fancy list markers\par}
-{\pard \ql \f0 \sa0 \li360 \fi-360 (2)\tx360\tab begins with 2\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 (2)\tx360\tab begins with 2\par}
{\pard \ql \f0 \sa180 \li360 \fi-360 (3)\tx360\tab and now 3\par}
{\pard \ql \f0 \sa180 \li360 \fi0 with a continuation\par}
{\pard \ql \f0 \sa0 \li720 \fi-360 iv.\tx360\tab sublist with roman numerals, starting with 4\par}
diff --git a/test/writer.texinfo b/test/writer.texinfo
index b55945751..53a25d515 100644
--- a/test/writer.texinfo
+++ b/test/writer.texinfo
@@ -453,6 +453,7 @@ this is an example list item indented with spaces
@enumerate 2
@item
begins with 2
+
@item
and now 3
diff --git a/test/writer.textile b/test/writer.textile
index 78e659091..e99f9ab6e 100644
--- a/test/writer.textile
+++ b/test/writer.textile
@@ -212,7 +212,7 @@ h2(#tabs-and-spaces). Tabs and spaces
h2(#fancy-list-markers). Fancy list markers
<ol start="2" style="list-style-type: decimal;">
-<li>begins with 2</li>
+<li><p>begins with 2</p></li>
<li><p>and now 3</p>
<p>with a continuation</p>
<ol start="4" style="list-style-type: lower-roman;">