diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-12-12 19:28:33 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-12-12 19:28:33 -0800 |
commit | 6e36375bdcf8875091e3716e951ebd5a2efc8f44 (patch) | |
tree | 709810becebdf7e7d211543225c802808078df6d /src/Text/Pandoc | |
parent | bbcf7a099c15452693e8c0b6be4587cba0cb4103 (diff) | |
download | pandoc-6e36375bdcf8875091e3716e951ebd5a2efc8f44.tar.gz |
LaTeX reader: Make command macros work everywhere, including non-math.
Environment macros still not supported.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index db148617e..8848be028 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -204,7 +204,7 @@ block :: LP Blocks block = (mempty <$ comment) <|> (mempty <$ ((spaceChar <|> newline) *> spaces)) <|> environment - <|> mempty <$ macro -- TODO improve macros, make them work everywhere + <|> mempty <$ macro <|> blockCommand <|> paragraph <|> grouped block @@ -327,11 +327,15 @@ inlineCommand = try $ do parseRaw <- getOption readerParseRaw star <- option "" (string "*") let name' = name ++ star - let rawargs = withRaw (skipopts *> option "" dimenarg - *> many braced) >>= applyMacros' . snd - let raw = if parseRaw - then (rawInline "latex" . (('\\':name') ++)) <$> rawargs - else mempty <$> rawargs + let raw = do + rawargs <- withRaw (skipopts *> option "" dimenarg *> many braced) + let rawcommand = '\\' : name ++ star ++ snd rawargs + transformed <- applyMacros' rawcommand + if transformed /= rawcommand + then parseFromString inlines transformed + else if parseRaw + then return $ rawInline "latex" rawcommand + else return mempty case M.lookup name' inlineCommands of Just p -> p <|> raw Nothing -> case M.lookup name inlineCommands of |