aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs9
-rw-r--r--test/Tests/Readers/Docx.hs4
-rw-r--r--test/docx/lists_sublist_reset.docxbin0 -> 12757 bytes
-rw-r--r--test/docx/lists_sublist_reset.native8
4 files changed, 20 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 9d17ab118..8b0b295ab 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -640,7 +640,14 @@ bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do
, ("text", txt)
, ("start", show start)
]
- modify $ \st -> st{ docxListState = M.insert (numId, lvl) start listState}
+ modify $ \st -> st{ docxListState =
+ -- expire all the continuation data for lists of level > this one:
+ -- a new level 1 list item resets continuation for level 2+
+ let expireKeys = [ (numid', lvl')
+ | (numid', lvl') <- M.keys listState
+ , lvl' > lvl
+ ]
+ in foldr M.delete (M.insert (numId, lvl) start listState) expireKeys }
blks <- bodyPartToBlocks (Paragraph pPr parparts)
return $ divWith ("", ["list-item"], kvs) blks
bodyPartToBlocks (ListItem pPr _ _ _ parparts) =
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs
index 583a6ec18..e107ff9ee 100644
--- a/test/Tests/Readers/Docx.hs
+++ b/test/Tests/Readers/Docx.hs
@@ -272,6 +272,10 @@ tests = [ testGroup "document"
"docx/lists_restarting.docx"
"docx/lists_restarting.native"
, testCompare
+ "sublists reset numbering to 1"
+ "docx/lists_sublist_reset.docx"
+ "docx/lists_sublist_reset.native"
+ , testCompare
"definition lists"
"docx/definition_list.docx"
"docx/definition_list.native"
diff --git a/test/docx/lists_sublist_reset.docx b/test/docx/lists_sublist_reset.docx
new file mode 100644
index 000000000..d4bf73852
--- /dev/null
+++ b/test/docx/lists_sublist_reset.docx
Binary files differ
diff --git a/test/docx/lists_sublist_reset.native b/test/docx/lists_sublist_reset.native
new file mode 100644
index 000000000..9ee80b2e8
--- /dev/null
+++ b/test/docx/lists_sublist_reset.native
@@ -0,0 +1,8 @@
+[OrderedList (1,Decimal,Period)
+ [[Para [Str "Head",Space,Str "1"]
+ ,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "Head",Space,Str "1.1"]]
+ ,[Para [Str "Head",Space,Str "1.2"]]]]
+ ,[Para [Str "Head",Space,Str "2"]
+ ,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "Head",Space,Str "2.1"]]]]]]