@@ -402,7 +402,7 @@ parPartToInlines (PlainOMath exps) = do
404isAnchorSpan :: Inline -> Bool
404isAnchorSpan :: Inline -> Bool
405−isAnchorSpan (Span (ident, classes, kvs) ils) =
405+isAnchorSpan (Span (_, classes, kvs) ils) =
406 classes == ["anchor"] &&
406 classes == ["anchor"] &&
407 null kvs &&
407 null kvs &&
@@ -415,14 +415,16 @@ makeHeaderAnchor :: Block -> DocxContext Block
415-- If there is an anchor already there (an anchor span in the header,
415-- If there is an anchor already there (an anchor span in the header,
416-- to be exact), we rename and associate the new id with the old one.
416-- to be exact), we rename and associate the new id with the old one.
417makeHeaderAnchor (Header n (_, classes, kvs) ils)
417makeHeaderAnchor (Header n (_, classes, kvs) ils)
418− | (x : xs) <- filter isAnchorSpan ils
418+ | xs <- filter isAnchorSpan ils
419− , (Span (ident, _, _) _) <- x
420− , notElem ident dummyAnchors =
419+ , idents <- filter (\i -> notElem i dummyAnchors) $
420+ map (\(Span (ident, _, _) _) -> ident) xs
421+ , not $ null idents =
422 hdrIDMap <- gets docxAnchorMap
423 hdrIDMap <- gets docxAnchorMap
423 let newIdent = uniqueIdent ils (M.elems hdrIDMap)
424 let newIdent = uniqueIdent ils (M.elems hdrIDMap)
425+ newMap = M.fromList $ map (\i -> (i, newIdent)) idents
424− modify $ \s -> s {docxAnchorMap = M.insert ident newIdent hdrIDMap}
426+ modify $ \s -> s {docxAnchorMap = M.union newMap hdrIDMap}
425− return $ Header n (newIdent, classes, kvs) (ils \\ (x:xs))
427+ return $ Header n (newIdent, classes, kvs) (ils \\ xs)
426-- Otherwise we just give it a name, and register that name (associate
428-- Otherwise we just give it a name, and register that name (associate
427-- it with itself.)
429-- it with itself.)
428makeHeaderAnchor (Header n (_, classes, kvs) ils) =
430makeHeaderAnchor (Header n (_, classes, kvs) ils) =