@@ -535,23 +535,18 @@ rewriteLink' l@(Link ils ('#':target, title)) = do
535 Nothing -> l
535 Nothing -> l
536rewriteLink' il = return il
536rewriteLink' il = return il
538−rewriteLink :: Blocks -> DocxContext Blocks
538+rewriteLinks :: [Block] -> DocxContext [Block]
539−rewriteLink ils = case viewl $ unMany ils of
541− x' <- walkM rewriteLink' x
539+rewriteLinks = mapM (walkM rewriteLink')
542− xs' <- rewriteLink $ Many xs
543− return $ (singleton x') <> xs'
544− EmptyL -> return ils
546bodyToOutput :: Body -> DocxContext (Meta, [Block], MediaBag)
541bodyToOutput :: Body -> DocxContext (Meta, [Block], MediaBag)
547bodyToOutput (Body bps) = do
542bodyToOutput (Body bps) = do
548 let (metabps, blkbps) = sepBodyParts bps
543 let (metabps, blkbps) = sepBodyParts bps
549 meta <- bodyPartsToMeta metabps
544 meta <- bodyPartsToMeta metabps
550 blks <- concatReduce <$> mapM bodyPartToBlocks blkbps
545 blks <- concatReduce <$> mapM bodyPartToBlocks blkbps
551− blks' <- rewriteLink blks
546+ blks' <- rewriteLinks $ blocksToDefinitions $ blocksToBullets $ toList blks
552 mediaBag <- gets docxMediaBag
547 mediaBag <- gets docxMediaBag
553 return $ (meta,
548 return $ (meta,
554− blocksToDefinitions $ blocksToBullets $ toList blks',
549+ blks',
555 mediaBag)
550 mediaBag)
557docxToOutput :: ReaderOptions -> Docx -> (Meta, [Block], MediaBag)
552docxToOutput :: ReaderOptions -> Docx -> (Meta, [Block], MediaBag)