@@ -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