From ac8ed1fa93f4ddb9d11744ec42c5224654d61dbf Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Thu, 4 Sep 2014 16:44:21 -0400 Subject: Docx reader: Rewrite rewriteLink to work with new headers. There could be new top-level headers after making lists, so we have to rewrite links after that. --- src/Text/Pandoc/Readers/Docx.hs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 8ebe59569..2f349b7f5 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -535,23 +535,18 @@ rewriteLink' l@(Link ils ('#':target, title)) = do Nothing -> l rewriteLink' il = return il -rewriteLink :: Blocks -> DocxContext Blocks -rewriteLink ils = case viewl $ unMany ils of - (x :< xs) -> do - x' <- walkM rewriteLink' x - xs' <- rewriteLink $ Many xs - return $ (singleton x') <> xs' - EmptyL -> return ils +rewriteLinks :: [Block] -> DocxContext [Block] +rewriteLinks = mapM (walkM rewriteLink') bodyToOutput :: Body -> DocxContext (Meta, [Block], MediaBag) bodyToOutput (Body bps) = do let (metabps, blkbps) = sepBodyParts bps meta <- bodyPartsToMeta metabps blks <- concatReduce <$> mapM bodyPartToBlocks blkbps - blks' <- rewriteLink blks + blks' <- rewriteLinks $ blocksToDefinitions $ blocksToBullets $ toList blks mediaBag <- gets docxMediaBag return $ (meta, - blocksToDefinitions $ blocksToBullets $ toList blks', + blks', mediaBag) docxToOutput :: ReaderOptions -> Docx -> (Meta, [Block], MediaBag) -- cgit v1.2.3