git.iko.soy/typeable/pandoc
on master help sign in
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.)

commit01ef573ac2f6620e9f70ae8965e5ccc664e3aec4 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 16 Jun 2014, 14:18 (12 years ago) parent4b6e279
1 file changed+5−9
src/Text/Pandoc/Readers/Org.hs+5−9
src/Text/Pandoc/Readers/Org.hs+5−9
@@ -38,10 +38,9 @@ import qualified Text.Pandoc.Parsing as P
3838import Text.Pandoc.Parsing hiding ( F, unF, askF, asksF, runF
3939 , newline, orderedListMarker
4040 , parseFromString
41− , updateLastStrPos )
41+ )
4242import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
4343import Text.Pandoc.Shared (compactify', compactify'DL)
44−import Text.Parsec.Pos (updatePosString)
4544import Text.TeXMath (texMathToPandoc, DisplayType(..))
4645
4746import Control.Applicative ( Applicative, pure
@@ -148,10 +147,6 @@ resetBlockAttributes :: OrgParser ()
148147resetBlockAttributes = updateState $ \s ->
149148 s{ orgStateBlockAttributes = orgStateBlockAttributes def }
150149
151−updateLastStrPos :: OrgParser ()
152−updateLastStrPos = getPosition >>= \p ->
153− updateState $ \s -> s{ orgStateLastStrPos = Just p }
154−
155150updateLastForbiddenCharPos :: OrgParser ()
156151updateLastForbiddenCharPos = getPosition >>= \p ->
157152 updateState $ \s -> s{ orgStateLastForbiddenCharPos = Just p}
@@ -1376,8 +1371,9 @@ maybeRight = either (const Nothing) Just
13761371inlineLaTeXCommand :: OrgParser String
13771372inlineLaTeXCommand = try $ do
13781373 rest <- getInput
1379− pos <- getPosition
13801374 case runParser rawLaTeXInline def "source" rest of
1381− Right (RawInline _ cs) -> cs <$ (setInput $ drop (length cs) rest)
1382− <* (setPosition $ updatePosString pos cs)
1375+ Right (RawInline _ cs) -> do
1376+ let len = length cs
1377+ count len anyChar
1378+ return cs
13831379 _ -> mzero