diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-02-28 11:14:03 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-02-28 11:14:03 -0800 |
commit | 7c6a3c0f69130c7df31c3b27623220a98fc88e9c (patch) | |
tree | 0d7c7b8d467281fbdffdd58ae931bd37ddc10b6a /src | |
parent | ea70495facf57d0016fe7f289c903a1046c02f8c (diff) | |
download | pandoc-7c6a3c0f69130c7df31c3b27623220a98fc88e9c.tar.gz |
LaTeX reader: handle interior `$` characters in math.
e.g. `$$\hbox{$i$}$$`.
Partially addresses #2743.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 9a1708331..2be55c9da 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -166,10 +166,18 @@ mathInline :: LP String -> LP Inlines mathInline p = math <$> (try p >>= applyMacros') mathChars :: LP String -mathChars = (concat <$>) $ - many $ - many1 (satisfy (\c -> c /= '$' && c /='\\')) - <|> (\c -> ['\\',c]) <$> try (char '\\' *> anyChar) +mathChars = + concat <$> many (escapedChar + <|> (snd <$> withRaw braced) + <|> many1 (satisfy isOrdChar)) + where escapedChar = try $ do char '\\' + c <- anyChar + return ['\\',c] + isOrdChar '$' = False + isOrdChar '{' = False + isOrdChar '}' = False + isOrdChar '\\' = False + isOrdChar _ = True quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines quoted' f starter ender = do |