@@ -46,9 +46,10 @@ import qualified Text.Pandoc.Builder as B
4646import Text.Pandoc.Builder (Blocks, Inlines, trimInlines, HasMeta(..))
4747import Text.Pandoc.Shared ( extractSpaces, addMetaField
4848 , escapeURI, safeRead, crFilter )
49−import Text.Pandoc.Options (ReaderOptions(readerExtensions), extensionEnabled,
50− Extension (Ext_epub_html_exts,
51− Ext_raw_html, Ext_native_divs, Ext_native_spans))
49+import Text.Pandoc.Options (
50+ ReaderOptions(readerExtensions,readerStripComments), extensionEnabled,
51+ Extension (Ext_epub_html_exts,
52+ Ext_raw_html, Ext_native_divs, Ext_native_spans))
5253import Text.Pandoc.Logging
5354import Text.Pandoc.Parsing hiding ((<|>))
5455import Text.Pandoc.Walk
@@ -1070,7 +1071,7 @@ _ `closes` _ = False
10701071--- parsers for use in markdown, textile readers
10711072
10721073-- | Matches a stretch of HTML in balanced tags.
1073−htmlInBalanced :: (Monad m)
1074+htmlInBalanced :: (HasReaderOptions st, Monad m)
10741075 => (Tag String -> Bool)
10751076 -> ParserT String st m String
10761077htmlInBalanced f = try $ do
@@ -1118,7 +1119,7 @@ hasTagWarning (TagWarning _:_) = True
11181119hasTagWarning _ = False
11191120
11201121-- | Matches a tag meeting a certain condition.
1121−htmlTag :: Monad m
1122+htmlTag :: (HasReaderOptions st, Monad m)
11221123 => (Tag String -> Bool)
11231124 -> ParserT [Char] st m (Tag String, String)
11241125htmlTag f = try $ do
@@ -1153,7 +1154,10 @@ htmlTag f = try $ do
11531154 count (length s + 4) anyChar
11541155 skipMany (satisfy (/='>'))
11551156 char '>'
1156− return (next, "<!--" <> s <> "-->")
1157+ stripComments <- getOption readerStripComments
1158+ if stripComments
1159+ then return (next, "")
1160+ else return (next, "<!--" <> s <> "-->")
11571161 | otherwise -> fail "bogus comment mode, HTML5 parse error"
11581162 TagOpen tagname attr -> do
11591163 guard $ all (isName . fst) attr