diff options
-rw-r--r-- | src/Text/Pandoc/Class.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 86158d632..df831c8b2 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -73,7 +73,7 @@ import qualified Text.Pandoc.Shared as IO ( readDataFile import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Compat.Time (UTCTime) import Text.Pandoc.Options (Verbosity(..)) -import Text.Parsec (ParsecT, SourcePos) +import Text.Parsec (ParsecT, SourcePos, getPosition) import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime) import Text.Pandoc.MIME (MimeType, getMimeType) import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds 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 |