git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in the markdown reader: HTML preceding a code block

could cause it to be parsed as a paragraph. (The problem is that the HTML parser used to eat all blank space after an HTML block, including the indentation of the code block.) Resolves Issue #39. + In Text.Pandoc.Readers.HTML, removed parsing of following space from rawHtmlBlock. + In Text.Pandoc.Readers.Markdown, modified rawHtmlBlocks so that indentation is eaten *only* on the first line after the HTML block. This means that in <div> foo <div> the foo won't be treated as a code block, but in <div> foo </div> it will. This seems the right approach for least suprise. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1164 788f1e2b-df1e-0410-8736-df70ead52e1b

commite37df6db69fc1d7832db19316ca7beb9cd54a24b authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 31 Dec 2007, 01:02 (19 years ago) parentad5cbb7
2 files changed+13−7
Text/Pandoc/Readers/HTML.hs+1−2 Text/Pandoc/Readers/Markdown.hs+12−5
Text/Pandoc/Readers/HTML.hs+1−2
@@ -207,9 +207,8 @@ htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definiti
207207
208208rawHtmlBlock = try $ do
209209 body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
210− sp <- many space
211210 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
213212
214213-- We don't want to parse </body> or </html> as raw HTML, since these
215214-- are handled in parseHtml.
Text/Pandoc/Readers/Markdown.hs+12−5
@@ -507,11 +507,18 @@ strictHtmlBlock = try $ do
507507 return $ tag ++ concat contents ++ end
508508
509509rawHtmlBlocks = do
510− htmlBlocks <- many1 rawHtmlBlock
511− let combined = concatMap (\(RawHtml str) -> str) htmlBlocks
512− let combined' = if not (null combined) && last combined == '\n'
513− then init combined -- strip extra newline
514− else combined
510+ htmlBlocks <- many1 $ do (RawHtml blk) <- rawHtmlBlock
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
521+ let combined' = if last combined == '\n' then init combined else combined
515522 return $ RawHtml combined'
516523
517524--