git.iko.soy/typeable/pandoc
on master help sign in
T.P.Readers.LaTeX.Parsing: add `[Tok]` parameter to rawLaTeXParser.
91c325cJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+13−6
@@ -126,14 +126,16 @@ rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s)
126 => ParserT String s m String
126 => ParserT String s m String
127rawLaTeXBlock = do
127rawLaTeXBlock = do
128 lookAhead (try (char '\\' >> letter))
128 lookAhead (try (char '\\' >> letter))
129+ inp <- getInput
130+ let toks = tokenize "source" $ T.pack inp
129− snd <$> (rawLaTeXParser False macroDef blocks
131+ snd <$> (rawLaTeXParser toks False macroDef blocks
130− <|> (rawLaTeXParser True
132+ <|> (rawLaTeXParser toks True
131 (do choice (map controlSeq
133 (do choice (map controlSeq
132 ["include", "input", "subfile", "usepackage"])
134 ["include", "input", "subfile", "usepackage"])
133 skipMany opt
135 skipMany opt
134 braced
136 braced
135 return mempty) blocks)
137 return mempty) blocks)
136− <|> rawLaTeXParser True
138+ <|> rawLaTeXParser toks True
137 (environment <|> blockCommand)
139 (environment <|> blockCommand)
138 (mconcat <$> (many (block <|> beginOrEndCommand))))
140 (mconcat <$> (many (block <|> beginOrEndCommand))))
139
141
@@ -155,11 +157,13 @@ rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
155 => ParserT String s m String
157 => ParserT String s m String
156rawLaTeXInline = do
158rawLaTeXInline = do
157 lookAhead (try (char '\\' >> letter))
159 lookAhead (try (char '\\' >> letter))
160+ inp <- getInput
161+ let toks = tokenize "source" $ T.pack inp
158 raw <- snd <$>
162 raw <- snd <$>
159− ( rawLaTeXParser True
163+ ( rawLaTeXParser toks True
160 (mempty <$ (controlSeq "input" >> skipMany opt >> braced))
164 (mempty <$ (controlSeq "input" >> skipMany opt >> braced))
161 inlines
165 inlines
162− <|> rawLaTeXParser True (inlineEnvironment <|> inlineCommand')
166+ <|> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')
163 inlines
167 inlines
164 )
168 )
165 finalbraces <- mconcat <$> many (try (string "{}")) -- see #5439
169 finalbraces <- mconcat <$> many (try (string "{}")) -- see #5439
@@ -168,7 +172,10 @@ rawLaTeXInline = do
168inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
172inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
169inlineCommand = do
173inlineCommand = do
170 lookAhead (try (char '\\' >> letter))
174 lookAhead (try (char '\\' >> letter))
175+ inp <- getInput
176+ let toks = tokenize "source" $ T.pack inp
171− fst <$> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines
177+ fst <$> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')
178+ inlines
172
179
173-- inline elements:
180-- inline elements:
174
181
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+3−4
@@ -200,10 +200,9 @@ withVerbatimMode parser = do
200 return result
200 return result
201
201
202rawLaTeXParser :: (PandocMonad m, HasMacros s, HasReaderOptions s)
202rawLaTeXParser :: (PandocMonad m, HasMacros s, HasReaderOptions s)
203+ => [Tok] -> Bool -> LP m a -> LP m a
203− => Bool -> LP m a -> LP m a -> ParserT String s m (a, String)
204+ -> ParserT String s m (a, String)
204−rawLaTeXParser retokenize parser valParser = do
205+rawLaTeXParser toks retokenize parser valParser = do
205− inp <- getInput
206− let toks = tokenize "source" $ T.pack inp
207 pstate <- getState
206 pstate <- getState
208 let lstate = def{ sOptions = extractReaderOptions pstate }
207 let lstate = def{ sOptions = extractReaderOptions pstate }
209 let lstate' = lstate { sMacros = extractMacros pstate }
208 let lstate' = lstate { sMacros = extractMacros pstate }