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.
This commit is contained in:
parent
52b78b10c8
commit
672b6dc7e6
2 changed files with 11 additions and 15 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue