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
This commit is contained in:
fiddlosopher 2007-12-24 04:22:20 +00:00
parent dad8e16330
commit 97992e6f7b

View file

@ -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