git.iko.soy/typeable/pandoc
on master help sign in
Changed parsing of code blocks in HTML reader:
6f16d52fiddlosopher
src/Text/Pandoc/Readers/HTML.hs+8−7
@@ -100,7 +100,7 @@ extractTagType ('<':rest) =
100 map toLower $ takeWhile isAlphaNum $ dropWhile isSpaceOrSlash rest
100 map toLower $ takeWhile isAlphaNum $ dropWhile isSpaceOrSlash rest
101extractTagType _ = ""
101extractTagType _ = ""
102
102
103−-- | Parse any HTML tag (closing or opening) and return text of tag
103+-- | Parse any HTML tag (opening or self-closing) and return text of tag
104anyHtmlTag = try $ do
104anyHtmlTag = try $ do
105 char '<'
105 char '<'
106 spaces
106 spaces
@@ -313,15 +313,16 @@ hrule = try $ do
313-- code blocks
313-- code blocks
314--
314--
315
315
316+-- Note: HTML tags in code blocks (e.g. for syntax highlighting) are
317+-- skipped, because they are not portable to output formats other than HTML.
316codeBlock = try $ do
318codeBlock = try $ do
317 htmlTag "pre"
319 htmlTag "pre"
318− spaces
319− htmlTag "code"
320− result <- manyTill anyChar (htmlEndTag "code")
320+ result <- manyTill
321− spaces
321+ (many1 (satisfy (/= '<')) <|>
322+ ((anyHtmlTag <|> anyHtmlEndTag) >> return ""))
322− htmlEndTag "pre"
323+ (htmlEndTag "pre")
323 return $ CodeBlock $ stripTrailingNewlines $
324 return $ CodeBlock $ stripTrailingNewlines $
324− decodeCharacterReferences result
325+ decodeCharacterReferences $ concat result
325
326
326--
327--
327-- block quotes
328-- block quotes