@@ -1131,8 +1131,14 @@ explicitLink = try $ do
11311131 (src',tit,attr) <- case reverse src of
11321132 '_':xs -> do
11331133 keyTable <- stateKeys <$> getState
1134− case M.lookup (toKey (reverse xs)) keyTable of
1135− Nothing -> fail "no corresponding key"
1134+ let key = toKey $ reverse xs
1135+ case M.lookup key keyTable of
1136+ Nothing -> do
1137+ pos <- getPosition
1138+ addWarning (Just pos) $
1139+ "Could not find reference for " ++
1140+ show key
1141+ return ("","",nullAttr)
11361142 Just ((s,t),a) -> return (s,t,a)
11371143 _ -> return (src, "", nullAttr)
11381144 return $ B.linkWith attr (escapeURI src') tit label''
@@ -1152,7 +1158,12 @@ referenceLink = try $ do
11521158 then mzero
11531159 else return (head anonKeys)
11541160 ((src,tit), attr) <- case M.lookup key keyTable of
1155− Nothing -> fail "no corresponding key"
1161+ Nothing -> do
1162+ pos <- getPosition
1163+ addWarning (Just pos) $
1164+ "Could not find reference for " ++
1165+ show key
1166+ return (("",""),nullAttr)
11561167 Just val -> return val
11571168 -- if anonymous link, remove key so it won't be used again
11581169 when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
@@ -1176,8 +1187,13 @@ subst = try $ do
11761187 (_,ref) <- withRaw $ enclosed (char '|') (char '|') inline
11771188 state <- getState
11781189 let substTable = stateSubstitutions state
1179− case M.lookup (toKey $ stripFirstAndLast ref) substTable of
1180− Nothing -> fail "no corresponding key"
1190+ let key = toKey $ stripFirstAndLast ref
1191+ case M.lookup key substTable of
1192+ Nothing -> do
1193+ pos <- getPosition
1194+ addWarning (Just pos) $
1195+ "Could not find reference for " ++ show key
1196+ return mempty
11811197 Just target -> return target
11821198
11831199note :: RSTParser Inlines
@@ -1188,7 +1204,11 @@ note = try $ do
11881204 state <- getState
11891205 let notes = stateNotes state
11901206 case lookup ref notes of
1191− Nothing -> fail "note not found"
1207+ Nothing -> do
1208+ pos <- getPosition
1209+ addWarning (Just pos) $
1210+ "Could not find note for " ++ show ref
1211+ return mempty
11921212 Just raw -> do
11931213 -- We temporarily empty the note list while parsing the note,
11941214 -- so that we don't get infinite loops with notes inside notes...