@@ -1131,8 +1131,14 @@ explicitLink = try $ do
1131 (src',tit,attr) <- case reverse src of
1131 (src',tit,attr) <- case reverse src of
1132 '_':xs -> do
1132 '_':xs -> do
1133 keyTable <- stateKeys <$> getState
1133 keyTable <- stateKeys <$> getState
1134+ let key = toKey $ reverse xs
1134− case M.lookup (toKey (reverse xs)) keyTable of
1135+ case M.lookup key keyTable of
1135− Nothing -> fail "no corresponding key"
1136+ Nothing -> do
1138+ addWarning (Just pos) $
1139+ "Could not find reference for " ++
1141+ return ("","",nullAttr)
1136 Just ((s,t),a) -> return (s,t,a)
1142 Just ((s,t),a) -> return (s,t,a)
1137 _ -> return (src, "", nullAttr)
1143 _ -> return (src, "", nullAttr)
1138 return $ B.linkWith attr (escapeURI src') tit label''
1144 return $ B.linkWith attr (escapeURI src') tit label''
@@ -1152,7 +1158,12 @@ referenceLink = try $ do
1152 then mzero
1158 then mzero
1153 else return (head anonKeys)
1159 else return (head anonKeys)
1154 ((src,tit), attr) <- case M.lookup key keyTable of
1160 ((src,tit), attr) <- case M.lookup key keyTable of
1155− Nothing -> fail "no corresponding key"
1161+ Nothing -> do
1163+ addWarning (Just pos) $
1164+ "Could not find reference for " ++
1166+ return (("",""),nullAttr)
1156 Just val -> return val
1167 Just val -> return val
1157 -- if anonymous link, remove key so it won't be used again
1168 -- if anonymous link, remove key so it won't be used again
1158 when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
1169 when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
@@ -1176,8 +1187,13 @@ subst = try $ do
1176 (_,ref) <- withRaw $ enclosed (char '|') (char '|') inline
1187 (_,ref) <- withRaw $ enclosed (char '|') (char '|') inline
1177 state <- getState
1188 state <- getState
1178 let substTable = stateSubstitutions state
1189 let substTable = stateSubstitutions state
1190+ let key = toKey $ stripFirstAndLast ref
1179− case M.lookup (toKey $ stripFirstAndLast ref) substTable of
1191+ case M.lookup key substTable of
1180− Nothing -> fail "no corresponding key"
1192+ Nothing -> do
1194+ addWarning (Just pos) $
1195+ "Could not find reference for " ++ show key
1181 Just target -> return target
1197 Just target -> return target
1183note :: RSTParser Inlines
1199note :: RSTParser Inlines
@@ -1188,7 +1204,11 @@ note = try $ do
1188 state <- getState
1204 state <- getState
1189 let notes = stateNotes state
1205 let notes = stateNotes state
1190 case lookup ref notes of
1206 case lookup ref notes of
1191− Nothing -> fail "note not found"
1207+ Nothing -> do
1209+ addWarning (Just pos) $
1210+ "Could not find note for " ++ show ref
1192 Just raw -> do
1212 Just raw -> do
1193 -- We temporarily empty the note list while parsing the note,
1213 -- We temporarily empty the note list while parsing the note,
1194 -- so that we don't get infinite loops with notes inside notes...
1214 -- so that we don't get infinite loops with notes inside notes...