@@ -59,11 +59,21 @@ readHtml = readWith parseHtml
5959-- Constants
6060--
6161
62+eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",
63+ "map", "area", "object", "script"]
64+
6265inlineHtmlTags = ["a", "abbr", "acronym", "b", "basefont", "bdo", "big",
6366 "br", "cite", "code", "dfn", "em", "font", "i", "img",
6467 "input", "kbd", "label", "q", "s", "samp", "select",
6568 "small", "span", "strike", "strong", "sub", "sup",
66− "textarea", "tt", "u", "var"]
69+ "textarea", "tt", "u", "var"] ++ eitherBlockOrInline
70+
71+blockHtmlTags = ["address", "blockquote", "center", "dir", "div",
72+ "dl", "fieldset", "form", "h1", "h2", "h3", "h4",
73+ "h5", "h6", "hr", "isindex", "menu", "noframes",
74+ "noscript", "ol", "p", "pre", "table", "ul", "dd",
75+ "dt", "frameset", "li", "tbody", "td", "tfoot",
76+ "th", "thead", "tr"] ++ eitherBlockOrInline
6777
6878--
6979-- HTML utility functions
@@ -171,12 +181,15 @@ htmlEndTag tag = try $ do
171181 char '>'
172182 return $ "</" ++ tag ++ ">"
173183
174−-- | Returns @True@ if the tag is an inline tag.
184+-- | Returns @True@ if the tag is (or can be) an inline tag.
175185isInline tag = (extractTagType tag) `elem` inlineHtmlTags
176186
187+-- | Returns @True@ if the tag is (or can be) a block tag.
188+isBlock tag = (extractTagType tag) `elem` blockHtmlTags
189+
177190anyHtmlBlockTag = try $ do
178191 tag <- anyHtmlTag <|> anyHtmlEndTag
179− if isInline tag then fail "inline tag" else return tag
192+ if isBlock tag then return tag else fail "inline tag"
180193
181194anyHtmlInlineTag = try $ do
182195 tag <- anyHtmlTag <|> anyHtmlEndTag
@@ -193,7 +206,7 @@ htmlBlockElement = choice [ htmlScript, htmlComment, xmlDec, definition ]
193206
194207rawHtmlBlock = try $ do
195208 notFollowedBy' (htmlTag "/body" <|> htmlTag "/html")
196− body <- htmlBlockElement <|> anyHtmlBlockTag
209+ body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
197210 sp <- many space
198211 state <- getState
199212 if stateParseRaw state then return (RawHtml (body ++ sp)) else return Null
@@ -260,8 +273,7 @@ parseHtml = do
260273 spaces
261274 optional (htmlEndTag "body")
262275 spaces
263− optional (htmlEndTag "html")
264− many anyChar -- ignore anything after </html>
276+ optional (htmlEndTag "html" >> many anyChar) -- ignore anything after </html>
265277 eof
266278 return $ Pandoc (Meta title authors date) blocks
267279