git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: handle interior `$` characters in math.

e.g. `$$\hbox{$i$}$$`. Partially addresses #2743.

commit7c6a3c0f69130c7df31c3b27623220a98fc88e9c authorJohn MacFarlane <jgm@berkeley.edu> dateSun 28 Feb 2016, 11:14 (11 years ago) parentea70495
1 file changed+12−4
src/Text/Pandoc/Readers/LaTeX.hs+12−4
src/Text/Pandoc/Readers/LaTeX.hs+12−4
@@ -166,10 +166,18 @@ mathInline :: LP String -> LP Inlines
166166mathInline p = math <$> (try p >>= applyMacros')
167167
168168mathChars :: LP String
169−mathChars = (concat <$>) $
170− many $
171− many1 (satisfy (\c -> c /= '$' && c /='\\'))
172− <|> (\c -> ['\\',c]) <$> try (char '\\' *> anyChar)
169+mathChars =
170+ concat <$> many (escapedChar
171+ <|> (snd <$> withRaw braced)
172+ <|> many1 (satisfy isOrdChar))
173+ where escapedChar = try $ do char '\\'
174+ c <- anyChar
175+ return ['\\',c]
176+ isOrdChar '$' = False
177+ isOrdChar '{' = False
178+ isOrdChar '}' = False
179+ isOrdChar '\\' = False
180+ isOrdChar _ = True
173181
174182quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
175183quoted' f starter ender = do