aboutsummaryrefslogtreecommitdiff
path: root/Text/Pandoc
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-10-18 23:42:23 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-10-18 23:42:23 +0000
commita2422504ff5c3ad40255cbefb86f5e48012e9de9 (patch)
tree001088728d7e92698e22dd0acab012bd03f5240a /Text/Pandoc
parent5b422262d3889c6b303b7942505ac164bd245546 (diff)
downloadpandoc-a2422504ff5c3ad40255cbefb86f5e48012e9de9.tar.gz
HTML reader: Don't interpret contents of <pre> blocks as markdown.
Added rawVerbatimBlock parser. Resolves Issue #94. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1468 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc')
-rw-r--r--Text/Pandoc/Readers/HTML.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/Text/Pandoc/Readers/HTML.hs b/Text/Pandoc/Readers/HTML.hs
index 10b7ad011..65e512b5e 100644
--- a/Text/Pandoc/Readers/HTML.hs
+++ b/Text/Pandoc/Readers/HTML.hs
@@ -320,10 +320,22 @@ htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definiti
rawHtmlBlock :: GenParser Char ParserState Block
rawHtmlBlock = try $ do
- body <- htmlBlockElement <|> anyHtmlBlockTag
+ body <- htmlBlockElement <|> rawVerbatimBlock <|> anyHtmlBlockTag
state <- getState
if stateParseRaw state then return (RawHtml body) else return Null
+-- This is a block whose contents should be passed through verbatim, not interpreted.
+rawVerbatimBlock :: GenParser Char ParserState [Char]
+rawVerbatimBlock = try $ do
+ start <- anyHtmlBlockTag
+ let tagtype = extractTagType start
+ if tagtype `elem` ["pre"]
+ then do
+ contents <- many (notFollowedBy' (htmlEndTag tagtype) >> anyChar)
+ end <- htmlEndTag tagtype
+ return $ start ++ contents ++ end
+ else fail "Not a verbatim block"
+
-- We don't want to parse </body> or </html> as raw HTML, since these
-- are handled in parseHtml.
rawHtmlBlock' :: GenParser Char ParserState Block