summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-01-21 10:17:58 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2022-01-21 10:17:58 -0800
commit672b6dc7e6cd5e9a0b614a37d15564a45446d9cb (patch)
tree12f4896dc13b85db16bfd3fa31ced76192d3269e /src
parent52b78b10c81e99926d560bc383938006be3b0458 (diff)
Remove retokenizing in rawLaTeXParser.
This was causing serious problems with `newif` commands. See #6096. And it didn't seem to make any difference for the tests; I assume that, unless there's some untested behavior, this is something that has now become unnecessary.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs15
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs11
2 files changed, 11 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index f42fcfbc4..2524905d3 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -138,14 +138,15 @@ rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s)
rawLaTeXBlock = do
lookAhead (try (char '\\' >> letter))
toks <- getInputTokens
- snd <$> (rawLaTeXParser toks False (macroDef (const mempty)) blocks
- <|> rawLaTeXParser toks True
- (do choice (map controlSeq
+ snd <$> (
+ rawLaTeXParser toks
+ (macroDef (const mempty) <|>
+ do choice (map controlSeq
["include", "input", "subfile", "usepackage"])
skipMany opt
braced
return mempty) blocks
- <|> rawLaTeXParser toks True
+ <|> rawLaTeXParser toks
(environment <|> blockCommand)
(mconcat <$> many (block <|> beginOrEndCommand)))
@@ -169,10 +170,10 @@ rawLaTeXInline = do
lookAhead (try (char '\\' >> letter))
toks <- getInputTokens
raw <- snd <$>
- ( rawLaTeXParser toks True
+ ( rawLaTeXParser toks
(mempty <$ (controlSeq "input" >> skipMany rawopt >> braced))
inlines
- <|> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')
+ <|> rawLaTeXParser toks (inlineEnvironment <|> inlineCommand')
inlines
)
finalbraces <- mconcat <$> many (try (string "{}")) -- see #5439
@@ -182,7 +183,7 @@ inlineCommand :: PandocMonad m => ParserT Sources ParserState m Inlines
inlineCommand = do
lookAhead (try (char '\\' >> letter))
toks <- getInputTokens
- fst <$> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')
+ fst <$> rawLaTeXParser toks (inlineEnvironment <|> inlineCommand')
inlines
-- inline elements:
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index 852b99b4d..4807c817f 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -255,9 +255,9 @@ withVerbatimMode parser = do
return result
rawLaTeXParser :: (PandocMonad m, HasMacros s, HasReaderOptions s, Show a)
- => [Tok] -> Bool -> LP m a -> LP m a
+ => [Tok] -> LP m a -> LP m a
-> ParserT Sources s m (a, Text)
-rawLaTeXParser toks retokenize parser valParser = do
+rawLaTeXParser toks parser valParser = do
pstate <- getState
let lstate = def{ sOptions = extractReaderOptions pstate }
let lstate' = lstate { sMacros = extractMacros pstate :| [] }
@@ -271,12 +271,7 @@ rawLaTeXParser toks retokenize parser valParser = do
case res' of
Left _ -> mzero
Right (endpos, toks') -> do
- res <- lift $ runParserT (do when retokenize $ do
- -- retokenize, applying macros
- ts <- many anyTok
- setInput ts
- rawparser)
- lstate' "chunk" toks'
+ res <- lift $ runParserT rawparser lstate' "chunk" toks'
case res of
Left _ -> mzero
Right ((val, raw), st) -> do