@@ -586,7 +586,7 @@ uri = try $ do
586mathInlineWith :: Stream s m Char => String -> String -> ParserT s st m String
586mathInlineWith :: Stream s m Char => String -> String -> ParserT s st m String
587mathInlineWith op cl = try $ do
587mathInlineWith op cl = try $ do
588 string op
588 string op
589− notFollowedBy space
589+ when (op == "$") $ notFollowedBy space
590 words' <- many1Till (count 1 (noneOf " \t\n\\")
590 words' <- many1Till (count 1 (noneOf " \t\n\\")
591 <|> (char '\\' >>
591 <|> (char '\\' >>
592 -- This next clause is needed because \text{..} can
592 -- This next clause is needed because \text{..} can
@@ -600,7 +600,7 @@ mathInlineWith op cl = try $ do
600 return " "
600 return " "
601 ) (try $ string cl)
601 ) (try $ string cl)
602 notFollowedBy digit -- to prevent capture of $5
602 notFollowedBy digit -- to prevent capture of $5
603− return $ concat words'
603+ return $ trim $ concat words'
605 inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String
605 inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String
606 inBalancedBraces 0 "" = do
606 inBalancedBraces 0 "" = do