@@ -824,6 +824,7 @@ inlineParsers = [ str
824824 , endline
825825 , code
826826 , charRef
827+ , (fourOrMore '*' <|> fourOrMore '_')
827828 , strong
828829 , emph
829830 , note
@@ -921,6 +922,12 @@ mathInline = try $ do
921922 notFollowedBy digit
922923 return $ intercalate " " words'
923924
925+-- to avoid performance problems, treat 4 or more _ or * in a row as a literal
926+-- rather than attempting to parse for emph/strong
927+fourOrMore :: Char -> GenParser Char st Inline
928+fourOrMore c = try $ count 4 (char c) >> many (char c) >>= \s ->
929+ return (Str $ replicate 4 c ++ s)
930+
924931emph :: GenParser Char ParserState Inline
925932emph = ((enclosed (char '*') (notFollowedBy' strong >> char '*') inline) <|>
926933 (enclosed (char '_') (notFollowedBy' strong >> char '_' >>