diff options
author | John MacFarlane <jgm@berkeley.edu> | 2011-01-05 12:25:47 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2011-01-05 12:25:47 -0800 |
commit | e126ab9efcec79850c217b979fd295a6730bfa6c (patch) | |
tree | ad866e4394f9f703eff8c18ca5256b87268c813a /src/Text/Pandoc/Readers | |
parent | c3071ff6e9ceb26c1a90c005ad4bb6661679ca40 (diff) | |
download | pandoc-e126ab9efcec79850c217b979fd295a6730bfa6c.tar.gz |
LaTeX reader: Parse inside arguments when ignoring commands.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index cdac5b2a5..7f726b2e1 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -39,8 +39,8 @@ import Text.Pandoc.Shared import Text.Pandoc.Parsing import Data.Maybe ( fromMaybe ) import Data.Char ( chr, toUpper ) -import Data.List ( isPrefixOf, isSuffixOf ) -import Control.Monad ( when, guard ) +import Data.List ( intercalate, isPrefixOf, isSuffixOf ) +import Control.Monad -- | Parse LaTeX from string and return 'Pandoc' document. readLaTeX :: ParserState -- ^ Parser state, including options for parser @@ -430,9 +430,11 @@ unknownCommand = try $ do else do (name, _, args) <- command spaces - if name `elem` commandsToIgnore - then return Null - else return $ Plain [Str $ concat args] + unless (name `elem` commandsToIgnore) $ do + -- put arguments back in input to be parsed + inp <- getInput + setInput $ intercalate " " args ++ inp + return Null commandsToIgnore :: [String] commandsToIgnore = ["special","pdfannot","pdfstringdef", "index","bibliography"] @@ -922,7 +924,7 @@ rawLaTeXInline = try $ do return $ TeX ("\\" ++ name ++ star ++ concat args) else do (name, _, args) <- command - spaces - if name `elem` commandsToIgnore - then return $ Str "" - else return $ Str (concat args) + unless (name `elem` commandsToIgnore) $ do + inp <- getInput + setInput $ intercalate " " args ++ inp + return $ Str "" |