@@ -49,7 +49,7 @@ import qualified Text.TeXMath.Readers.MathML.EntityMap as MathMLEntityMap
4949import Control.Arrow (first)
5050import Control.Monad (foldM, guard, liftM, liftM2, mplus, mzero, when)
5151import Control.Monad.Reader (Reader, runReader, ask, asks, local)
52−import Data.Char (isAlphaNum, toLower)
52+import Data.Char (isAlphaNum, isSpace, toLower)
5353import Data.Default
5454import Data.List (intersperse, isPrefixOf, isSuffixOf)
5555import qualified Data.Map as M
@@ -1587,8 +1587,8 @@ inlineLaTeX = try $ do
15871587 state :: ParserState
15881588 state = def{ stateOptions = def{ readerParseRaw = True }}
15891589
1590− texMathToPandoc inp = (maybeRight $ readTeX inp) >>=
1591− writePandoc DisplayInline
1590+ texMathToPandoc :: String -> Maybe [Inline]
1591+ texMathToPandoc cs = (maybeRight $ readTeX cs) >>= writePandoc DisplayInline
15921592
15931593maybeRight :: Either a b -> Maybe b
15941594maybeRight = either (const Nothing) Just
@@ -1598,9 +1598,11 @@ inlineLaTeXCommand = try $ do
15981598 rest <- getInput
15991599 case runParser rawLaTeXInline def "source" rest of
16001600 Right (RawInline _ cs) -> do
1601− let len = length cs
1601+ -- drop any trailing whitespace, those should not be part of the command
1602+ let cmdNoSpc = takeWhile (not . isSpace) $ cs
1603+ let len = length cmdNoSpc
16021604 count len anyChar
1603− return cs
1605+ return cmdNoSpc
16041606 _ -> mzero
16051607
16061608smart :: OrgParser (F Inlines)