From c76eec97d4a8f78d3c1c212664364015a21b7404 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 10 Feb 2017 10:00:23 +0100 Subject: LaTeX reader: Improved messages for skipped environments. --- src/Text/Pandoc/Readers/LaTeX.hs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 8745437a4..cc69786cf 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -938,12 +938,20 @@ inlineEnvironment = try $ do rawEnv :: PandocMonad m => String -> LP m Blocks rawEnv name = do exts <- getOption readerExtensions + let parseRaw = extensionEnabled Ext_raw_tex exts rawOptions <- mconcat <$> many rawopt - let addBegin x = "\\begin{" ++ name ++ "}" ++ rawOptions ++ x - if extensionEnabled Ext_raw_tex exts - then (rawBlock "latex" . addBegin) <$> - (withRaw (env name blocks) >>= applyMacros' . snd) - else env name blocks + let beginCommand = "\\begin{" ++ name ++ "}" ++ rawOptions + unless parseRaw $ do + pos1 <- getPosition + warningWithPos pos1 $ "Skipped " ++ beginCommand + (bs, raw) <- withRaw $ env name blocks + raw' <- applyMacros' raw + if parseRaw + then return $ rawBlock "latex" $ beginCommand ++ raw' + else do + pos2 <- getPosition + warningWithPos pos2 $ "Skipped \\end{" ++ name ++ "}" + return bs ---- -- cgit v1.2.3