git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2900 from tarleb/org-symbol-fix
f7a5c17John MacFarlane
src/Text/Pandoc/Readers/Org.hs+7−5
@@ -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 }}
1589
1589
1590− texMathToPandoc inp = (maybeRight $ readTeX inp) >>=
1590+ texMathToPandoc :: String -> Maybe [Inline]
1591− writePandoc DisplayInline
1591+ texMathToPandoc cs = (maybeRight $ readTeX cs) >>= writePandoc DisplayInline
1592
1592
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
1605
1607
1606smart :: OrgParser (F Inlines)
1608smart :: OrgParser (F Inlines)
tests/Tests/Readers/Org.hs+4
@@ -328,6 +328,10 @@ tests =
328 "\\copy" =?>
328 "\\copy" =?>
329 para "©"
329 para "©"
330
330
331+ , "MathML symbols, space separated" =:
332+ "\\ForAll \\Auml" =?>
333+ para "∀ Ä"
334+
331 , "LaTeX citation" =:
335 , "LaTeX citation" =:
332 "\\cite{Coffee}" =?>
336 "\\cite{Coffee}" =?>
333 let citation = Citation
337 let citation = Citation