git.iko.soy/typeable/pandoc
on master help sign in
Powerpoint writer: Ignore anchor links to nowehere.

We don't convert a '#target' ExternalTarget to an InternalTarget if `target` is not in the AnchorMap. We just remove the link. This prevents broken links in the Powerpoint output.

commita7d131cf442f6d93f1e3183d26b855ca5f7112af authorJesse Rosenthal <jrosenthal@jhu.edu> dateMon 15 Jan 2018, 08:54 (9 years ago) parent0e16155
1 file changed+6−3
src/Text/Pandoc/Writers/Powerpoint/Presentation.hs+6−3
src/Text/Pandoc/Writers/Powerpoint/Presentation.hs+6−3
@@ -680,9 +680,12 @@ replaceAnchor :: PandocMonad m => ParaElem -> Pres m ParaElem
680680replaceAnchor (Run rProps s)
681681 | Just (ExternalTarget ('#':anchor, _)) <- rLink rProps = do
682682 anchorMap <- gets stAnchorMap
683− return $ case M.lookup anchor anchorMap of
684− Just n -> Run (rProps{rLink = Just $ InternalTarget n}) s
685− Nothing -> Run rProps s
683+ -- If the anchor is not in the anchormap, we just remove the
684+ -- link.
685+ let rProps' = case M.lookup anchor anchorMap of
686+ Just n -> rProps{rLink = Just $ InternalTarget n}
687+ Nothing -> rProps{rLink = Nothing}
688+ return $ Run rProps' s
686689replaceAnchor pe = return pe
687690
688691blocksToPresentation :: PandocMonad m => [Block] -> Pres m Presentation