diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-02-09 22:21:07 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-02-09 22:21:07 +0100 |
commit | 87507e1b9cf976aeb39a9308a2d050ea6e060585 (patch) | |
tree | 78cc07c7ca585beb2420a5b1b6145a5a4edb0af3 /src/Text/Pandoc/Readers | |
parent | 0a4ba91994c875b0eaf22b76a6153c0d1de0f018 (diff) | |
download | pandoc-87507e1b9cf976aeb39a9308a2d050ea6e060585.tar.gz |
LaTeX reader: Issue warnings when skipping unknown latex commands.
See #3392.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 4fb3bb077..7233c05c5 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -296,7 +296,7 @@ inBrackets x = str "[" <> x <> str "]" -- eat an optional argument and one or more arguments in braces ignoreInlines :: PandocMonad m => String -> (String, LP m Inlines) -ignoreInlines name = (name, doraw <|> (mempty <$ optargs)) +ignoreInlines name = (name, doraw <|> (optargs >> ignore name)) where optargs = skipopts *> skipMany (try $ optional sp *> braced) contseq = '\\':name doraw = (rawInline "latex" . (contseq ++) . snd) <$> @@ -304,8 +304,14 @@ ignoreInlines name = (name, doraw <|> (mempty <$ optargs)) guard $ extensionEnabled Ext_raw_tex exts withRaw optargs) +ignore :: (Monoid a, PandocMonad m) => String -> LP m a +ignore name = do + pos <- getPosition + warningWithPos pos $ "Skipped \\" ++ name ++ " and its arguments" + return mempty + ignoreBlocks :: PandocMonad m => String -> (String, LP m Blocks) -ignoreBlocks name = (name, doraw <|> (mempty <$ optargs)) +ignoreBlocks name = (name, doraw <|> (optargs >> ignore name)) where optargs = skipopts *> skipMany (try $ optional sp *> braced) contseq = '\\':name doraw = (rawBlock "latex" . (contseq ++) . snd) <$> @@ -438,7 +444,7 @@ inlineCommand = try $ do then parseFromString inlines transformed else if extensionEnabled Ext_raw_tex exts then return $ rawInline "latex" rawcommand - else return mempty + else ignore name (lookupListDefault mzero [name',name] inlineCommands <* optional (try (string "{}"))) <|> raw @@ -489,7 +495,7 @@ inlineCommands = M.fromList $ , ("sim", lit "~") , ("label", unlessParseRaw >> (inBrackets <$> tok)) , ("ref", unlessParseRaw >> (inBrackets <$> tok)) - , ("noindent", unlessParseRaw >> return mempty) + , ("noindent", unlessParseRaw >> ignore "noindent") , ("textgreek", tok) , ("sep", lit ",") , ("cref", unlessParseRaw >> (inBrackets <$> tok)) -- from cleveref.sty |