From 97992e6f7b3953297b036c3cf68eb175e1aa6806 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Mon, 24 Dec 2007 04:22:20 +0000 Subject: Improved handling of raw HTML in Markdown reader. (Resolves Issue #36.) Tags that can be either block or inline (e.g. ) should be treated as block when appropriate and as inline when appropriate. Thus, for example, hi should be treated as a paragraph with inline tags, while hi should be treated as a paragraph within tags. + Moved htmlBlock after para in list of block parsers. This ensures that tags that can be either block or inline get parsed as inline when appropriate. + Modified rawHtmlInline' so that block elements aren't treated as inline. + Modified para parser so that paragraphs containing only HTML tags and blank space are not allowed. Treat these as raw HTML blocks instead. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1154 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Readers/Markdown.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Text/Pandoc') diff --git a/Text/Pandoc/Readers/Markdown.hs b/Text/Pandoc/Readers/Markdown.hs index 2c0bf8db8..365218b3d 100644 --- a/Text/Pandoc/Readers/Markdown.hs +++ b/Text/Pandoc/Readers/Markdown.hs @@ -235,9 +235,9 @@ block = choice [ header , hrule , list , blockQuote - , htmlBlock , rawLaTeXEnvironment' , para + , htmlBlock , plain , nullBlock ] "block" @@ -448,8 +448,16 @@ definitionList = do -- paragraph block -- +isHtmlOrBlank (HtmlInline _) = True +isHtmlOrBlank (Space) = True +isHtmlOrBlank (LineBreak) = True +isHtmlOrBlank _ = False + para = try $ do result <- many1 inline + if all isHtmlOrBlank result + then fail "treat as raw HTML" + else return () newline blanklines <|> do st <- getState if stateStrict st @@ -886,8 +894,8 @@ rawLaTeXInline' = failIfStrict >> rawLaTeXInline rawHtmlInline' = do st <- getState - result <- choice $ if stateStrict st - then [htmlBlockElement, anyHtmlTag, anyHtmlEndTag] - else [htmlBlockElement, anyHtmlInlineTag] + result <- if stateStrict st + then choice [htmlBlockElement, anyHtmlTag, anyHtmlEndTag] + else anyHtmlInlineTag return $ HtmlInline result -- cgit v1.2.3