Skip to content

Commit

Permalink
Reset docxListState if header has list information.
Browse files Browse the repository at this point in the history
See #10258.
  • Loading branch information
jgm committed Oct 4, 2024
1 parent 0515c20 commit e6a1bb4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Text/Pandoc/Readers/Docx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,24 @@ bodyPartToBlocks (Paragraph pPr parparts)
let addNum = if hasNumbering && isNothing (numbered pPr)
then (++ ["unnumbered"])
else id
case numbered pPr of
Nothing -> pure ()
Just Number{ numberNumId = numId
, numberLvl = lvl
, numberLvlInfo = levelInfo } -> do
-- We check whether this current numId has previously been used,
-- since Docx expects us to pick up where we left off.
listState <- gets docxListState
let startFromState = M.lookup (numId, lvl) listState
Level _ _ _ startFromLevelInfo = levelInfo
start = case startFromState of
Just x -> x + 1
Nothing -> fromMaybe 1 startFromLevelInfo
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 notExpired (_, lvl') _ = lvl' <= lvl
in M.insert (numId, lvl) start (M.filterWithKey notExpired listState) }
makeHeaderAnchor $
headerWith ("", addNum classes, []) n ils
| Just Number{ numberNumId = numId
Expand Down

0 comments on commit e6a1bb4

Please sign in to comment.