From a7d131cf442f6d93f1e3183d26b855ca5f7112af Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Mon, 15 Jan 2018 08:54:42 -0500 Subject: 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. --- src/Text/Pandoc/Writers/Powerpoint/Presentation.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs index e68f5eb57..5ced4e8a8 100644 --- a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs +++ b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs @@ -680,9 +680,12 @@ replaceAnchor :: PandocMonad m => ParaElem -> Pres m ParaElem replaceAnchor (Run rProps s) | Just (ExternalTarget ('#':anchor, _)) <- rLink rProps = do anchorMap <- gets stAnchorMap - return $ case M.lookup anchor anchorMap of - Just n -> Run (rProps{rLink = Just $ InternalTarget n}) s - Nothing -> Run rProps s + -- If the anchor is not in the anchormap, we just remove the + -- link. + let rProps' = case M.lookup anchor anchorMap of + Just n -> rProps{rLink = Just $ InternalTarget n} + Nothing -> rProps{rLink = Nothing} + return $ Run rProps' s replaceAnchor pe = return pe blocksToPresentation :: PandocMonad m => [Block] -> Pres m Presentation -- cgit v1.2.3