diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-05-09 10:17:56 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-05-09 10:17:56 -0700 |
commit | fd9ec835ec1447fb6040ee63a1fa8ee13b19d555 (patch) | |
tree | 038efac64bde36cb82bf95ea24719b566bae41b3 /src/Text/Pandoc/Readers/Org.hs | |
parent | c1b19b17c4853bb0113a340c54a1726b7e31e1a8 (diff) | |
parent | d32878b84b08f2f8e007b9b06c393a41e2ebe5fe (diff) | |
download | pandoc-fd9ec835ec1447fb6040ee63a1fa8ee13b19d555.tar.gz |
Merge pull request #2907 from tarleb/org-fixes
Org fixes (reader and writer)
Diffstat (limited to 'src/Text/Pandoc/Readers/Org.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index db1e70ea0..5a50a8f34 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -1581,8 +1581,8 @@ inlineLaTeX = try $ do parseAsMathMLSym :: String -> Maybe Inlines parseAsMathMLSym cs = B.str <$> MathMLEntityMap.getUnicode (clean cs) - -- dropWhileEnd would be nice here, but it's not available before base 4.5 - where clean = reverse . dropWhile (`elem` ("{}" :: String)) . reverse . drop 1 + -- drop initial backslash and any trailing "{}" + where clean = dropWhileEnd (`elem` ("{}" :: String)) . drop 1 state :: ParserState state = def{ stateOptions = def{ readerParseRaw = True }} @@ -1598,13 +1598,18 @@ inlineLaTeXCommand = try $ do rest <- getInput case runParser rawLaTeXInline def "source" rest of Right (RawInline _ cs) -> do - -- drop any trailing whitespace, those should not be part of the command - let cmdNoSpc = takeWhile (not . isSpace) $ cs + -- drop any trailing whitespace, those are not be part of the command as + -- far as org mode is concerned. + let cmdNoSpc = dropWhileEnd isSpace cs let len = length cmdNoSpc count len anyChar return cmdNoSpc _ -> mzero +-- Taken from Data.OldList. +dropWhileEnd :: (a -> Bool) -> [a] -> [a] +dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) [] + smart :: OrgParser (F Inlines) smart = do getOption readerSmart >>= guard |