From f86ac89383110f2755a53d49dc508da873bcaf0a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 21 Jan 2019 20:54:12 -0800 Subject: HTML and markdown: treat textarea as a verbatim environment. We don't want to parse its contents as Markdown or HTML. Closes #5241. --- src/Text/Pandoc/Readers/HTML.hs | 4 +++- src/Text/Pandoc/Readers/Markdown.hs | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 8d3c1abb4..cf326b072 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -412,7 +412,9 @@ pDiv = try $ do pRawHtmlBlock :: PandocMonad m => TagParser m Blocks pRawHtmlBlock = do - raw <- T.unpack <$> (pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag) + raw <- T.unpack <$> + (pHtmlBlock "script" <|> pHtmlBlock "style" <|> pHtmlBlock "textarea" + <|> pRawTag) exts <- getOption readerExtensions if extensionEnabled Ext_raw_html exts && not (null raw) then return $ B.rawBlock "html" raw diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index b463898a0..8d28abb2f 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1106,9 +1106,8 @@ htmlBlock :: PandocMonad m => MarkdownParser m (F Blocks) htmlBlock = do guardEnabled Ext_raw_html try (do - (TagOpen t attrs) <- lookAhead $ fst <$> htmlTag isBlockTag - (guard (t `elem` ["pre","style","script"]) >> - (return . B.rawBlock "html") <$> rawVerbatimBlock) + (TagOpen _ attrs) <- lookAhead $ fst <$> htmlTag isBlockTag + (return . B.rawBlock "html") <$> rawVerbatimBlock <|> (do guardEnabled Ext_markdown_attribute oldMarkdownAttribute <- stateMarkdownAttribute <$> getState markdownAttribute <- @@ -1141,10 +1140,11 @@ strictHtmlBlock = htmlInBalanced (not . isInlineTag) rawVerbatimBlock :: PandocMonad m => MarkdownParser m String rawVerbatimBlock = htmlInBalanced isVerbTag - where isVerbTag (TagOpen "pre" _) = True - isVerbTag (TagOpen "style" _) = True - isVerbTag (TagOpen "script" _) = True - isVerbTag _ = False + where isVerbTag (TagOpen "pre" _) = True + isVerbTag (TagOpen "style" _) = True + isVerbTag (TagOpen "script" _) = True + isVerbTag (TagOpen "textarea" _) = True + isVerbTag _ = False rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks) rawTeXBlock = do -- cgit v1.2.3