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
This commit is contained in:
parent
ad5cbb78d0
commit
e37df6db69
2 changed files with 13 additions and 7 deletions
|
@ -207,9 +207,8 @@ htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definiti
|
||||||
|
|
||||||
rawHtmlBlock = try $ do
|
rawHtmlBlock = try $ do
|
||||||
body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
|
body <- htmlBlockElement <|> anyHtmlTag <|> anyHtmlEndTag
|
||||||
sp <- many space
|
|
||||||
state <- getState
|
state <- getState
|
||||||
if stateParseRaw state then return (RawHtml (body ++ sp)) else return Null
|
if stateParseRaw state then return (RawHtml body) else return Null
|
||||||
|
|
||||||
-- We don't want to parse </body> or </html> as raw HTML, since these
|
-- We don't want to parse </body> or </html> as raw HTML, since these
|
||||||
-- are handled in parseHtml.
|
-- are handled in parseHtml.
|
||||||
|
|
|
@ -507,11 +507,18 @@ strictHtmlBlock = try $ do
|
||||||
return $ tag ++ concat contents ++ end
|
return $ tag ++ concat contents ++ end
|
||||||
|
|
||||||
rawHtmlBlocks = do
|
rawHtmlBlocks = do
|
||||||
htmlBlocks <- many1 rawHtmlBlock
|
htmlBlocks <- many1 $ do (RawHtml blk) <- rawHtmlBlock
|
||||||
let combined = concatMap (\(RawHtml str) -> str) htmlBlocks
|
sps <- do sp1 <- many spaceChar
|
||||||
let combined' = if not (null combined) && last combined == '\n'
|
sp2 <- option "" (blankline >> return "\n")
|
||||||
then init combined -- strip extra newline
|
sp3 <- many spaceChar
|
||||||
else combined
|
sp4 <- option "" blanklines
|
||||||
|
return $ sp1 ++ sp2 ++ sp3 ++ sp4
|
||||||
|
-- note: we want raw html to be able to
|
||||||
|
-- precede a code block, when separated
|
||||||
|
-- by a blank line
|
||||||
|
return $ blk ++ sps
|
||||||
|
let combined = concat htmlBlocks
|
||||||
|
let combined' = if last combined == '\n' then init combined else combined
|
||||||
return $ RawHtml combined'
|
return $ RawHtml combined'
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in a new issue