HTML and markdown: treat textarea as a verbatim environment.

We don't want to parse its contents as Markdown or HTML.

Closes #5241.
This commit is contained in:
John MacFarlane 2019-01-21 20:54:12 -08:00
parent 847ff4f83d
commit f86ac89383
3 changed files with 22 additions and 8 deletions

View file

@ -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

View file

@ -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 <-
@ -1144,6 +1143,7 @@ rawVerbatimBlock = htmlInBalanced isVerbTag
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)

12
test/command/5241.md Normal file
View file

@ -0,0 +1,12 @@
```
% pandoc -f markdown -t html5
<textarea>
one
*two*
</textarea>
^D
<textarea>
one
*two*
</textarea>
```