aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-07-21 22:44:18 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-07-21 22:44:18 -0700
commitfa2c008ae5edf36b5345d56e859d0b5cf7a14e69 (patch)
tree89b9b11afef2add55d43151b6338500ee95432a3
parent6a96090f7832f8f0b51c6812ab9b89cf0b1dfb7e (diff)
downloadpandoc-fa2c008ae5edf36b5345d56e859d0b5cf7a14e69.tar.gz
Fix regression: allow HTML comments containing `--`.
Technically this isn't allowed in an HTML comment, but we've always allowed it, and so do most other implementations. It is handy if e.g. you want to put command line arguments in HTML comments.
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs8
-rw-r--r--tests/Tests/Readers/Markdown.hs3
2 files changed, 7 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index c43bc5295..fcba16e04 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -923,10 +923,6 @@ htmlTag f = try $ do
let (next : rest) = canonicalizeTags $ parseTagsOptions
parseOptions{ optTagWarning = True } inp
guard $ f next
- -- we get a TagWarning on things like
- -- <www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>
- -- which should NOT be parsed as an HTML tag, see #2277
- guard $ not $ hasTagWarning rest
case next of
TagComment s
| "<!--" `isPrefixOf` inp -> do
@@ -936,6 +932,10 @@ htmlTag f = try $ do
return (next, "<!--" ++ s ++ "-->")
| otherwise -> fail "bogus comment mode, HTML5 parse error"
_ -> do
+ -- we get a TagWarning on things like
+ -- <www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>
+ -- which should NOT be parsed as an HTML tag, see #2277
+ guard $ not $ hasTagWarning rest
rendered <- manyTill anyChar (char '>')
return (next, rendered ++ ">")
diff --git a/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs
index 17bfd332e..a5425ffb3 100644
--- a/tests/Tests/Readers/Markdown.hs
+++ b/tests/Tests/Readers/Markdown.hs
@@ -176,6 +176,9 @@ tests = [ testGroup "inline code"
, "invalid tag (issue #1820" =:
"</ div></.div>" =?>
para (text "</ div></.div>")
+ , "technically invalid comment" =:
+ "<!-- pandoc --help -->" =?>
+ rawBlock "html" "<!-- pandoc --help -->"
]
, "unbalanced brackets" =:
"[[[[[[[[[[[[[[[hi" =?> para (text "[[[[[[[[[[[[[[[hi")