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