aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-14 23:23:14 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-14 23:23:14 +0000
commit800b03ba505c1c40dbe1432e3686f41d8f4a31f1 (patch)
tree3c8547f4ddca7c064a41cb3b0bddf8b55a22974c /src
parent139b2ed6d18940eb41497f5379359b92a347cf61 (diff)
downloadpandoc-800b03ba505c1c40dbe1432e3686f41d8f4a31f1.tar.gz
LaTeX reader: ignore \section, \pdfannot, \pdfstringdef.
Resolves Issue #202. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1887 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 233f5a3d5..f10f0e219 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -39,6 +39,7 @@ import Text.Pandoc.Shared
import Data.Maybe ( fromMaybe )
import Data.Char ( chr )
import Data.List ( isPrefixOf, isSuffixOf )
+import Control.Monad ( when )
-- | Parse LaTeX from string and return 'Pandoc' document.
readLaTeX :: ParserState -- ^ Parser state, including options for parser
@@ -400,21 +401,22 @@ unknownCommand = try $ do
notFollowedBy' $ choice $ map end ["itemize", "enumerate", "description",
"document"]
state <- getState
- if stateParserContext state == ListItemState
- then notFollowedBy' $ string "\\item"
- else return ()
+ when (stateParserContext state == ListItemState) $
+ notFollowedBy' (string "\\item")
if stateParseRaw state
then do
(name, star, args) <- command
spaces
return $ Plain [TeX ("\\" ++ name ++ star ++ concat args)]
- else do -- skip unknown command, leaving arguments to be parsed
- char '\\'
- letter
- many (letter <|> digit)
- optional (try $ string "{}")
+ else do
+ (name, _, args) <- command
spaces
- return Null
+ if name `elem` commandsToIgnore
+ then return Null
+ else return $ Plain [Str $ concat args]
+
+commandsToIgnore :: [String]
+commandsToIgnore = ["special","pdfannot","pdfstringdef"]
-- latex comment
comment :: GenParser Char st Block
@@ -780,9 +782,9 @@ rawLaTeXInline = try $ do
then do
(name, star, args) <- command
return $ TeX ("\\" ++ name ++ star ++ concat args)
- else do -- skip unknown command, leaving arguments to be parsed
- char '\\'
- letter
- many (letter <|> digit)
- optional (try $ string "{}")
- return $ Str ""
+ else do
+ (name, _, args) <- command
+ spaces
+ if name `elem` commandsToIgnore
+ then return $ Str ""
+ else return $ Str (concat args)