@@ -190,7 +190,7 @@ where
190190
191191import Control.Monad.Identity
192192import Control.Monad.Reader
193−import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper,
193+import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isAsciiLower,
194194 isPunctuation, isSpace, ord, toLower, toUpper)
195195import Data.Default
196196import Data.Functor (($>))
@@ -444,12 +444,13 @@ spaceChar = satisfy $ \c -> c == ' ' || c == '\t'
444444-- | Parses a nonspace, nonnewline character.
445445nonspaceChar :: Stream s m Char => ParserT s st m Char
446446nonspaceChar = satisfy (not . isSpaceChar)
447− where
448− isSpaceChar ' ' = True
449− isSpaceChar '\t' = True
450− isSpaceChar '\n' = True
451− isSpaceChar '\r' = True
452− isSpaceChar _ = False
447+
448+isSpaceChar :: Char -> Bool
449+isSpaceChar ' ' = True
450+isSpaceChar '\t' = True
451+isSpaceChar '\n' = True
452+isSpaceChar '\r' = True
453+isSpaceChar _ = False
453454
454455-- | Skips zero or more spaces or tabs.
455456skipSpaces :: Stream s m Char => ParserT s st m ()
@@ -682,7 +683,9 @@ mathInlineWith :: Stream s m Char => Text -> Text -> ParserT s st m Text
682683mathInlineWith op cl = try $ do
683684 textStr op
684685 when (op == "$") $ notFollowedBy space
685− words' <- many1Till (countChar 1 (noneOf " \t\n\\")
686+ words' <- many1Till (
687+ (T.singleton <$>
688+ satisfy (\c -> not (isSpaceChar c || c == '\\')))
686689 <|> (char '\\' >>
687690 -- This next clause is needed because \text{..} can
688691 -- contain $, \(\), etc.
@@ -840,13 +843,13 @@ defaultNum = do
840843-- | Parses a lowercase letter and returns (LowerAlpha, number).
841844lowerAlpha :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
842845lowerAlpha = do
843− ch <- oneOf ['a'..'z']
846+ ch <- satisfy isAsciiLower
844847 return (LowerAlpha, ord ch - ord 'a' + 1)
845848
846849-- | Parses an uppercase letter and returns (UpperAlpha, number).
847850upperAlpha :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
848851upperAlpha = do
849− ch <- oneOf ['A'..'Z']
852+ ch <- satisfy isAsciiUpper
850853 return (UpperAlpha, ord ch - ord 'A' + 1)
851854
852855-- | Parses a roman numeral i or I