summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Markdown.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-20 17:44:28 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-07-20 17:44:28 -0700
commitb6c769084eff0fe865c13590dee0737e41ba4e43 (patch)
treed2231e7b5d04ff25acdef5739ab5961c28eadc9d /src/Text/Pandoc/Readers/Markdown.hs
parenta243afb55104b0e5e1ddf62f301477a545381634 (diff)
Fix behavior of `markdown_attribute` extension.
It now works as in PHP markdown extra. Setting `markdown="1"` on an outer tag affects all contained tags until it is reversed with `markdown="0"`. Closes #1378. Added `stateMarkdownAttribute` to `ParserState`.
Diffstat (limited to 'src/Text/Pandoc/Readers/Markdown.hs')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 4120a5a11..04b3fa684 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -939,10 +939,21 @@ htmlBlock = do
(TagOpen t attrs) <- lookAhead $ fst <$> htmlTag isBlockTag
(guard (t `elem` ["pre","style","script"]) >>
(return . B.rawBlock "html") <$> rawVerbatimBlock)
- <|> (guardEnabled Ext_markdown_attribute >>
- case lookup "markdown" attrs of
- Just "1" -> rawHtmlBlocks
- _ -> htmlBlock')
+ <|> (do guardEnabled Ext_markdown_attribute
+ oldMarkdownAttribute <- stateMarkdownAttribute <$> getState
+ markdownAttribute <-
+ case lookup "markdown" attrs of
+ Just "0" -> False <$ updateState (\st -> st{
+ stateMarkdownAttribute = False })
+ Just _ -> True <$ updateState (\st -> st{
+ stateMarkdownAttribute = True })
+ Nothing -> return oldMarkdownAttribute
+ res <- if markdownAttribute
+ then rawHtmlBlocks
+ else htmlBlock'
+ updateState $ \st -> st{ stateMarkdownAttribute =
+ oldMarkdownAttribute }
+ return res)
<|> (guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks))
<|> htmlBlock'