diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-06-16 14:18:06 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-06-16 14:18:06 -0700 |
commit | 01ef573ac2f6620e9f70ae8965e5ccc664e3aec4 (patch) | |
tree | 0b62f57f3cc9f49498c1a82cc022bbd2448a18d2 /src | |
parent | 4b6e279e3acf01ace9831a9e98d76af92befe60f (diff) | |
download | pandoc-01ef573ac2f6620e9f70ae8965e5ccc664e3aec4.tar.gz |
Org reader: fixed #1342.
This change rewrites `inlineLaTeXCommand` so that parsec will
know when input is being consumed. Previously a run-time
error would be produced with some input involving raw latex.
(I believe this does not affect the last release, as the inline
latex reading was added recently.)
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index c3ea8d7c2..0e872abf0 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -38,10 +38,9 @@ import qualified Text.Pandoc.Parsing as P import Text.Pandoc.Parsing hiding ( F, unF, askF, asksF, runF , newline, orderedListMarker , parseFromString - , updateLastStrPos ) + ) import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline) import Text.Pandoc.Shared (compactify', compactify'DL) -import Text.Parsec.Pos (updatePosString) import Text.TeXMath (texMathToPandoc, DisplayType(..)) import Control.Applicative ( Applicative, pure @@ -148,10 +147,6 @@ resetBlockAttributes :: OrgParser () resetBlockAttributes = updateState $ \s -> s{ orgStateBlockAttributes = orgStateBlockAttributes def } -updateLastStrPos :: OrgParser () -updateLastStrPos = getPosition >>= \p -> - updateState $ \s -> s{ orgStateLastStrPos = Just p } - updateLastForbiddenCharPos :: OrgParser () updateLastForbiddenCharPos = getPosition >>= \p -> updateState $ \s -> s{ orgStateLastForbiddenCharPos = Just p} @@ -1376,8 +1371,9 @@ maybeRight = either (const Nothing) Just inlineLaTeXCommand :: OrgParser String inlineLaTeXCommand = try $ do rest <- getInput - pos <- getPosition case runParser rawLaTeXInline def "source" rest of - Right (RawInline _ cs) -> cs <$ (setInput $ drop (length cs) rest) - <* (setPosition $ updatePosString pos cs) + Right (RawInline _ cs) -> do + let len = length cs + count len anyChar + return cs _ -> mzero |