Markdown reader: Parse span, div tags as Span, Div elements.
Assuming markdown_in_html extension is set.
This commit is contained in:
parent
5a5a252216
commit
3117c668a7
1 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue