diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-08-15 22:39:14 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-08-17 17:11:51 -0700 |
commit | 3117c668a7d245689bfc291d5d9a64cb3178b52c (patch) | |
tree | a901f9948a1628f303627f6b306baddf91323ce3 /src/Text/Pandoc | |
parent | 5a5a2522163d73c3b91db2cb2b73e697a5dcfb23 (diff) | |
download | pandoc-3117c668a7d245689bfc291d5d9a64cb3178b52c.tar.gz |
Markdown reader: Parse span, div tags as Span, Div elements.
Assuming markdown_in_html extension is set.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 906dd10f2..535fc02c6 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -446,6 +446,7 @@ block = choice [ mempty <$ blanklines , header , lhsCodeBlock , rawTeXBlock + , divHtml , htmlBlock , table , lineBlock @@ -1355,6 +1356,7 @@ inline = choice [ whitespace , superscript , inlineNote -- after superscript because of ^[link](/foo)^ , autoLink + , spanHtml , rawHtmlInline , escapedChar , rawLaTeXInline' @@ -1755,6 +1757,26 @@ inBrackets parser = do char ']' return $ "[" ++ contents ++ "]" +spanHtml :: MarkdownParser (F Inlines) +spanHtml = try $ do + guardEnabled Ext_markdown_in_html_blocks + (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "span" []) + contents <- mconcat <$> manyTill inline (htmlTag (~== TagClose "span")) + let ident = maybe "" id $ lookup "id" attrs + let classes = maybe [] words $ lookup "class" attrs + let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"] + return $ B.spanWith (ident, classes, keyvals) <$> contents + +divHtml :: MarkdownParser (F Blocks) +divHtml = try $ do + guardEnabled Ext_markdown_in_html_blocks + (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "div" []) + contents <- mconcat <$> manyTill block (htmlTag (~== TagClose "div")) + let ident = maybe "" id $ lookup "id" attrs + let classes = maybe [] words $ lookup "class" attrs + let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"] + return $ B.divWith (ident, classes, keyvals) <$> contents + rawHtmlInline :: MarkdownParser (F Inlines) rawHtmlInline = do guardEnabled Ext_raw_html |