git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in the markdown reader: HTML preceding a code block
e37df6dfiddlosopher
Text/Pandoc/Readers/HTML.hs+1−2
@@ -207,9 +207,8 @@ htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definiti
207
207
208rawHtmlBlock = try $ do
208rawHtmlBlock = try $ do
209 body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
209 body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
210− sp <- many space
211 state <- getState
210 state <- getState
212− if stateParseRaw state then return (RawHtml (body ++ sp)) else return Null
211+ if stateParseRaw state then return (RawHtml body) else return Null
213
212
214-- We don't want to parse </body> or </html> as raw HTML, since these
213-- We don't want to parse </body> or </html> as raw HTML, since these
215-- are handled in parseHtml.
214-- are handled in parseHtml.
Text/Pandoc/Readers/Markdown.hs+12−5
@@ -507,11 +507,18 @@ strictHtmlBlock = try $ do
507 return $ tag ++ concat contents ++ end
507 return $ tag ++ concat contents ++ end
508
508
509rawHtmlBlocks = do
509rawHtmlBlocks = do
510− htmlBlocks <- many1 rawHtmlBlock
510+ htmlBlocks <- many1 $ do (RawHtml blk) <- rawHtmlBlock
511− let combined = concatMap (\(RawHtml str) -> str) htmlBlocks
511+ sps <- do sp1 <- many spaceChar
512+ sp2 <- option "" (blankline >> return "\n")
513+ sp3 <- many spaceChar
514+ sp4 <- option "" blanklines
515+ return $ sp1 ++ sp2 ++ sp3 ++ sp4
516+ -- note: we want raw html to be able to
517+ -- precede a code block, when separated
518+ -- by a blank line
519+ return $ blk ++ sps
520+ let combined = concat htmlBlocks
512− let combined' = if not (null combined) && last combined == '\n'
521+ let combined' = if last combined == '\n' then init combined else combined
513− then init combined -- strip extra newline
514− else combined
515 return $ RawHtml combined'
522 return $ RawHtml combined'
516
523
517--
524--