git.iko.soy/typeable/pandoc
on master help sign in
Improved handling of raw HTML in Markdown reader. (Resolves Issue #36.)

Tags that can be either block or inline (e.g. <ins>) should be treated as block when appropriate and as inline when appropriate. Thus, for example, <ins>hi</ins> should be treated as a paragraph with inline <ins> tags, while <ins> hi </ins> should be treated as a paragraph within <ins> 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

commit97992e6f7b3953297b036c3cf68eb175e1aa6806 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 24 Dec 2007, 04:22 (19 years ago) parentdad8e16
1 file changed+12−4
Text/Pandoc/Readers/Markdown.hs+12−4
Text/Pandoc/Readers/Markdown.hs+12−4
@@ -235,9 +235,9 @@ block = choice [ header
235235 , hrule
236236 , list
237237 , blockQuote
238− , htmlBlock
239238 , rawLaTeXEnvironment'
240239 , para
240+ , htmlBlock
241241 , plain
242242 , nullBlock ] <?> "block"
243243
@@ -448,8 +448,16 @@ definitionList = do
448448-- paragraph block
449449--
450450
451+isHtmlOrBlank (HtmlInline _) = True
452+isHtmlOrBlank (Space) = True
453+isHtmlOrBlank (LineBreak) = True
454+isHtmlOrBlank _ = False
455+
451456para = try $ do
452457 result <- many1 inline
458+ if all isHtmlOrBlank result
459+ then fail "treat as raw HTML"
460+ else return ()
453461 newline
454462 blanklines <|> do st <- getState
455463 if stateStrict st
@@ -886,8 +894,8 @@ rawLaTeXInline' = failIfStrict >> rawLaTeXInline
886894
887895rawHtmlInline' = do
888896 st <- getState
889− result <- choice $ if stateStrict st
890− then [htmlBlockElement, anyHtmlTag, anyHtmlEndTag]
891− else [htmlBlockElement, anyHtmlInlineTag]
897+ result <- if stateStrict st
898+ then choice [htmlBlockElement, anyHtmlTag, anyHtmlEndTag]
899+ else anyHtmlInlineTag
892900 return $ HtmlInline result
893901