git.iko.soy/typeable/pandoc
on master help sign in
Fix behavior of `markdown_attribute` extension.
b6c7690John MacFarlane
src/Text/Pandoc/Parsing.hs+2
@@ -879,6 +879,7 @@ data ParserState = ParserState
879 -- annotate role classes too).
879 -- annotate role classes too).
880 stateCaption :: Maybe Inlines, -- ^ Caption in current environment
880 stateCaption :: Maybe Inlines, -- ^ Caption in current environment
881 stateInHtmlBlock :: Maybe String, -- ^ Tag type of HTML block being parsed
881 stateInHtmlBlock :: Maybe String, -- ^ Tag type of HTML block being parsed
882+ stateMarkdownAttribute :: Bool, -- ^ True if in markdown=1 context
882 stateWarnings :: [String] -- ^ Warnings generated by the parser
883 stateWarnings :: [String] -- ^ Warnings generated by the parser
883 }
884 }
884
885
@@ -958,6 +959,7 @@ defaultParserState =
958 stateRstCustomRoles = M.empty,
959 stateRstCustomRoles = M.empty,
959 stateCaption = Nothing,
960 stateCaption = Nothing,
960 stateInHtmlBlock = Nothing,
961 stateInHtmlBlock = Nothing,
962+ stateMarkdownAttribute = False,
961 stateWarnings = []}
963 stateWarnings = []}
962
964
963-- | Succeed only if the extension is enabled.
965-- | Succeed only if the extension is enabled.
src/Text/Pandoc/Readers/Markdown.hs+15−4
@@ -939,10 +939,21 @@ htmlBlock = do
939 (TagOpen t attrs) <- lookAhead $ fst <$> htmlTag isBlockTag
939 (TagOpen t attrs) <- lookAhead $ fst <$> htmlTag isBlockTag
940 (guard (t `elem` ["pre","style","script"]) >>
940 (guard (t `elem` ["pre","style","script"]) >>
941 (return . B.rawBlock "html") <$> rawVerbatimBlock)
941 (return . B.rawBlock "html") <$> rawVerbatimBlock)
942− <|> (guardEnabled Ext_markdown_attribute >>
942+ <|> (do guardEnabled Ext_markdown_attribute
943+ oldMarkdownAttribute <- stateMarkdownAttribute <$> getState
944+ markdownAttribute <-
943− case lookup "markdown" attrs of
945+ case lookup "markdown" attrs of
944− Just "1" -> rawHtmlBlocks
946+ Just "0" -> False <$ updateState (\st -> st{
947+ stateMarkdownAttribute = False })
948+ Just _ -> True <$ updateState (\st -> st{
949+ stateMarkdownAttribute = True })
950+ Nothing -> return oldMarkdownAttribute
951+ res <- if markdownAttribute
952+ then rawHtmlBlocks
945− _ -> htmlBlock')
953+ else htmlBlock'
954+ updateState $ \st -> st{ stateMarkdownAttribute =
955+ oldMarkdownAttribute }
956+ return res)
946 <|> (guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks))
957 <|> (guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks))
947 <|> htmlBlock'
958 <|> htmlBlock'
948
959