git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: Don't interpret contents of style tags as markdown.
d989a78fiddlosopher
Text/Pandoc/Readers/HTML.hs+9−2
@@ -196,7 +196,14 @@ htmlScript = try $ do
196 rest <- manyTill anyChar (htmlEndTag "script")
196 rest <- manyTill anyChar (htmlEndTag "script")
197 return $ open ++ rest ++ "</script>"
197 return $ open ++ rest ++ "</script>"
198
198
199+-- | Parses material between style tags.
200+-- Style tags must be treated differently, because they can contain CSS
201+htmlStyle = try $ do
202+ open <- string "<style"
203+ rest <- manyTill anyChar (htmlEndTag "style")
204+ return $ open ++ rest ++ "</style>"
205+
199−htmlBlockElement = choice [ htmlScript, htmlComment, xmlDec, definition ]
206+htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definition ]
200
207
201rawHtmlBlock = try $ do
208rawHtmlBlock = try $ do
202 body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
209 body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
@@ -435,7 +442,7 @@ code = try $ do
435 joinWithSep " " $ lines result
442 joinWithSep " " $ lines result
436
443
437rawHtmlInline = do
444rawHtmlInline = do
438− result <- htmlScript <|> htmlComment <|> anyHtmlInlineTag
445+ result <- htmlScript <|> htmlStyle <|> htmlComment <|> anyHtmlInlineTag
439 state <- getState
446 state <- getState
440 if stateParseRaw state then return (HtmlInline result) else return (Str "")
447 if stateParseRaw state then return (HtmlInline result) else return (Str "")
441
448