Docx reader: fix list number resumption for sublists. Closes #4324.
The first list item of a sublist should not resume numbering from the number of the last sublist item of the same level, if that sublist was a sublist of a different list item. That is, we should not get: ``` 1. one 1. sub one 2. sub two 2. two 3. sub one ```
This commit is contained in:
parent
e906e5ac23
commit
530bfe5f5a
4 changed files with 20 additions and 1 deletions
|
@ -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) =
|
||||
|
|
|
@ -271,6 +271,10 @@ tests = [ testGroup "document"
|
|||
"lists restarting after interruption"
|
||||
"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"
|
||||
|
|
BIN
test/docx/lists_sublist_reset.docx
Normal file
BIN
test/docx/lists_sublist_reset.docx
Normal file
Binary file not shown.
8
test/docx/lists_sublist_reset.native
Normal file
8
test/docx/lists_sublist_reset.native
Normal file
|
@ -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"]]]]]]
|
Loading…
Add table
Reference in a new issue