git.iko.soy/typeable/pandoc
on master help sign in
Bug fixes in readers:
4399db4fiddlosopher
src/Text/Pandoc/Readers/HTML.hs+18−6
@@ -59,11 +59,21 @@ readHtml = readWith parseHtml
59-- Constants
59-- Constants
60--
60--
61
61
62+eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",
63+ "map", "area", "object", "script"]
64+
62inlineHtmlTags = ["a", "abbr", "acronym", "b", "basefont", "bdo", "big",
65inlineHtmlTags = ["a", "abbr", "acronym", "b", "basefont", "bdo", "big",
63 "br", "cite", "code", "dfn", "em", "font", "i", "img",
66 "br", "cite", "code", "dfn", "em", "font", "i", "img",
64 "input", "kbd", "label", "q", "s", "samp", "select",
67 "input", "kbd", "label", "q", "s", "samp", "select",
65 "small", "span", "strike", "strong", "sub", "sup",
68 "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
67
77
68--
78--
69-- HTML utility functions
79-- HTML utility functions
@@ -171,12 +181,15 @@ htmlEndTag tag = try $ do
171 char '>'
181 char '>'
172 return $ "</" ++ tag ++ ">"
182 return $ "</" ++ tag ++ ">"
173
183
174−-- | Returns @True@ if the tag is an inline tag.
184+-- | Returns @True@ if the tag is (or can be) an inline tag.
175isInline tag = (extractTagType tag) `elem` inlineHtmlTags
185isInline tag = (extractTagType tag) `elem` inlineHtmlTags
176
186
187+-- | Returns @True@ if the tag is (or can be) a block tag.
188+isBlock tag = (extractTagType tag) `elem` blockHtmlTags
189+
177anyHtmlBlockTag = try $ do
190anyHtmlBlockTag = try $ do
178 tag <- anyHtmlTag <|> anyHtmlEndTag
191 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"
180
193
181anyHtmlInlineTag = try $ do
194anyHtmlInlineTag = try $ do
182 tag <- anyHtmlTag <|> anyHtmlEndTag
195 tag <- anyHtmlTag <|> anyHtmlEndTag
@@ -193,7 +206,7 @@ htmlBlockElement = choice [ htmlScript, htmlComment, xmlDec, definition ]
193
206
194rawHtmlBlock = try $ do
207rawHtmlBlock = try $ do
195 notFollowedBy' (htmlTag "/body" <|> htmlTag "/html")
208 notFollowedBy' (htmlTag "/body" <|> htmlTag "/html")
196− body <- htmlBlockElement <|> anyHtmlBlockTag
209+ body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
197 sp <- many space
210 sp <- many space
198 state <- getState
211 state <- getState
199 if stateParseRaw state then return (RawHtml (body ++ sp)) else return Null
212 if stateParseRaw state then return (RawHtml (body ++ sp)) else return Null
@@ -260,8 +273,7 @@ parseHtml = do
260 spaces
273 spaces
261 optional (htmlEndTag "body")
274 optional (htmlEndTag "body")
262 spaces
275 spaces
263− optional (htmlEndTag "html")
264− many anyChar -- ignore anything after </html>
276+ optional (htmlEndTag "html" >> many anyChar) -- ignore anything after </html>
265 eof
277 eof
266 return $ Pandoc (Meta title authors date) blocks
278 return $ Pandoc (Meta title authors date) blocks
267
279
src/Text/Pandoc/Readers/LaTeX.hs+2−1
@@ -117,7 +117,8 @@ parseLaTeX = do
117 spaces
117 spaces
118 blocks <- parseBlocks
118 blocks <- parseBlocks
119 spaces
119 spaces
120+ optional $ try (string "\\end{document}" >> many anyChar)
120− optional $ try (string "\\end{document}") -- might not be present (fragment)
121+ -- might not be present (fragment)
121 spaces
122 spaces
122 eof
123 eof
123 state <- getState
124 state <- getState