@@ -166,10 +166,18 @@ mathInline :: LP String -> LP Inlines
166166mathInline p = math <$> (try p >>= applyMacros')
167167
168168mathChars :: LP String
169−mathChars = (concat <$>) $
170− many $
171− many1 (satisfy (\c -> c /= '$' && c /='\\'))
172− <|> (\c -> ['\\',c]) <$> try (char '\\' *> anyChar)
169+mathChars =
170+ concat <$> many (escapedChar
171+ <|> (snd <$> withRaw braced)
172+ <|> many1 (satisfy isOrdChar))
173+ where escapedChar = try $ do char '\\'
174+ c <- anyChar
175+ return ['\\',c]
176+ isOrdChar '$' = False
177+ isOrdChar '{' = False
178+ isOrdChar '}' = False
179+ isOrdChar '\\' = False
180+ isOrdChar _ = True
173181
174182quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
175183quoted' f starter ender = do