@@ -321,14 +321,19 @@ containsFootnotes = p
321321 s (_:xs) = p xs
322322 s [] = False
323323
324+-- | Return True if string should be escaped with <verbatim> tags
325+shouldEscapeString :: Bool -> String -> Bool
326+shouldEscapeString isInsideLinkDescription s =
327+ any (`elem` ("#*<=|" :: String)) s ||
328+ "::" `isInfixOf` s ||
329+ "~~" `isInfixOf` s ||
330+ "[[" `isInfixOf` s ||
331+ ("]" `isInfixOf` s && isInsideLinkDescription) ||
332+ containsFootnotes s
333+
324334conditionalEscapeString :: Bool -> String -> String
325335conditionalEscapeString isInsideLinkDescription s =
326− if any (`elem` ("#*<=|" :: String)) s ||
327− "::" `isInfixOf` s ||
328− "~~" `isInfixOf` s ||
329− "[[" `isInfixOf` s ||
330− ("]" `isInfixOf` s && isInsideLinkDescription) ||
331− containsFootnotes s
336+ if shouldEscapeString isInsideLinkDescription s
332337 then escapeString s
333338 else s
334339