git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2900 from tarleb/org-symbol-fix

Org reader: fix spacing after LaTeX-style symbols

commitf7a5c17a63d48b26e3c676170e8673f3011cf452 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 5 May 2016, 13:20 (10 years ago) parentcc9a9c7405c3e9
2 files changed+11−5
src/Text/Pandoc/Readers/Org.hs+7−5 tests/Tests/Readers/Org.hs+4
src/Text/Pandoc/Readers/Org.hs+7−5
@@ -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)
tests/Tests/Readers/Org.hs+4
@@ -328,6 +328,10 @@ tests =
328328 "\\copy" =?>
329329 para "©"
330330
331+ , "MathML symbols, space separated" =:
332+ "\\ForAll \\Auml" =?>
333+ para "∀ Ä"
334+
331335 , "LaTeX citation" =:
332336 "\\cite{Coffee}" =?>
333337 let citation = Citation