Added Ext_raw_html extension.

Closes #556 -- you can now specify markdown-raw_html as your
input format.  (Read: markdown minus raw_html.)
This commit is contained in:
John MacFarlane 2012-08-12 22:04:23 -07:00
parent 6f24fdb658
commit 27304513f6
3 changed files with 15 additions and 5 deletions

6
README
View file

@ -1854,9 +1854,13 @@ HTML, Slidy, DZSlides, S5, EPUB
Raw HTML
--------
**Extenion: `raw_html`**
Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
(except verbatim contexts, where `<`, `>`, and `&` are interpreted
literally).
literally). (Techncially this is not an extension, since standard
markdown allows it, but it has been made an extension so that it can
be disabled if desired.)
The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,
DZSlides, EPUB, Markdown, and Textile output, and suppressed in other

View file

@ -58,6 +58,7 @@ data Extension = Ext_footnotes
| Ext_pipe_tables
| Ext_citations
| Ext_raw_tex
| Ext_raw_html
| Ext_tex_math_dollars
| Ext_tex_math_single_backslash
| Ext_tex_math_double_backslash
@ -97,6 +98,7 @@ pandocExtensions = Set.fromList
, Ext_pipe_tables
, Ext_citations
, Ext_raw_tex
, Ext_raw_html
, Ext_tex_math_dollars
, Ext_latex_macros
, Ext_delimited_code_blocks
@ -119,7 +121,8 @@ pandocExtensions = Set.fromList
]
strictExtensions :: Set Extension
strictExtensions = Set.empty
strictExtensions = Set.fromList
[ Ext_raw_html ]
data ReaderOptions = ReaderOptions{
readerExtensions :: Set Extension -- ^ Syntax extensions

View file

@ -729,9 +729,11 @@ htmlElement :: Parser [Char] ParserState String
htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag)
htmlBlock :: Parser [Char] ParserState (F Blocks)
htmlBlock = return . B.rawBlock "html" <$>
((guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks)
<|> htmlBlock')
htmlBlock = do
guardEnabled Ext_raw_html
res <- (guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks)
<|> htmlBlock'
return $ return $ B.rawBlock "html" res
htmlBlock' :: Parser [Char] ParserState String
htmlBlock' = try $ do
@ -1507,6 +1509,7 @@ inBrackets parser = do
rawHtmlInline :: Parser [Char] ParserState (F Inlines)
rawHtmlInline = do
guardEnabled Ext_raw_html
mdInHtml <- option False $
guardEnabled Ext_markdown_in_html_blocks >> return True
(_,result) <- if mdInHtml