aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-02-10 08:17:47 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-02-10 08:18:08 +0100
commita84a360f7a8dbd8da180ca46faaa7dfae025149d (patch)
tree041499086e08e81dfaa511339a3a4a7a434671ee /src/Text
parent87507e1b9cf976aeb39a9308a2d050ea6e060585 (diff)
downloadpandoc-a84a360f7a8dbd8da180ca46faaa7dfae025149d.tar.gz
HTML reader: Added warnings for ignored material.
See #3392.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 219ee81b6..a464847fb 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -68,10 +68,9 @@ import Data.Monoid ((<>))
import Text.Parsec.Error
import qualified Data.Set as Set
import Text.Pandoc.Error
-import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Class (PandocMonad, report, warningWithPos)
import Control.Monad.Except (throwError)
-
-- | Convert HTML-formatted string to 'Pandoc' document.
readHtml :: PandocMonad m
=> ReaderOptions -- ^ Reader options
@@ -370,7 +369,16 @@ pRawHtmlBlock = do
exts <- getOption readerExtensions
if extensionEnabled Ext_raw_html exts && not (null raw)
then return $ B.rawBlock "html" raw
- else return mempty
+ else ignore raw
+
+ignore :: (Monoid a, PandocMonad m) => String -> TagParser m a
+ignore raw = do
+ pos <- getPosition
+ -- raw can be null for tags like <!DOCTYPE>; see paRawTag
+ -- in this case we don't want a warning:
+ unless (null raw) $
+ warningWithPos pos $ "Skipped " ++ raw
+ return mempty
pHtmlBlock :: PandocMonad m => String -> TagParser m String
pHtmlBlock t = try $ do
@@ -691,9 +699,10 @@ pRawHtmlInline = do
then pSatisfy (not . isBlockTag)
else pSatisfy isInlineTag
exts <- getOption readerExtensions
+ let raw = renderTags' [result]
if extensionEnabled Ext_raw_html exts
- then return $ B.rawInline "html" $ renderTags' [result]
- else return mempty
+ then return $ B.rawInline "html" raw
+ else ignore raw
mathMLToTeXMath :: String -> Either String String
mathMLToTeXMath s = writeTeX <$> readMathML s