git.iko.soy/typeable/pandoc
on master help sign in
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.

commitac8ed1fa93f4ddb9d11744ec42c5224654d61dbf authorJesse Rosenthal <jrosenthal@jhu.edu> dateThu 4 Sep 2014, 16:44 (12 years ago) parent7fe5450
1 file changed+4−9
src/Text/Pandoc/Readers/Docx.hs+4−9
src/Text/Pandoc/Readers/Docx.hs+4−9
@@ -535,23 +535,18 @@ rewriteLink' l@(Link ils ('#':target, title)) = do
535535 Nothing -> l
536536rewriteLink' il = return il
537537
538−rewriteLink :: Blocks -> DocxContext Blocks
539−rewriteLink ils = case viewl $ unMany ils of
540− (x :< xs) -> do
541− x' <- walkM rewriteLink' x
542− xs' <- rewriteLink $ Many xs
543− return $ (singleton x') <> xs'
544− EmptyL -> return ils
538+rewriteLinks :: [Block] -> DocxContext [Block]
539+rewriteLinks = mapM (walkM rewriteLink')
545540
546541bodyToOutput :: Body -> DocxContext (Meta, [Block], MediaBag)
547542bodyToOutput (Body bps) = do
548543 let (metabps, blkbps) = sepBodyParts bps
549544 meta <- bodyPartsToMeta metabps
550545 blks <- concatReduce <$> mapM bodyPartToBlocks blkbps
551− blks' <- rewriteLink blks
546+ blks' <- rewriteLinks $ blocksToDefinitions $ blocksToBullets $ toList blks
552547 mediaBag <- gets docxMediaBag
553548 return $ (meta,
554− blocksToDefinitions $ blocksToBullets $ toList blks',
549+ blks',
555550 mediaBag)
556551
557552docxToOutput :: ReaderOptions -> Docx -> (Meta, [Block], MediaBag)