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:
parent
847ff4f83d
commit
f86ac89383
3 changed files with 22 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
12
test/command/5241.md
Normal file
12
test/command/5241.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
```
|
||||
% pandoc -f markdown -t html5
|
||||
<textarea>
|
||||
one
|
||||
*two*
|
||||
</textarea>
|
||||
^D
|
||||
<textarea>
|
||||
one
|
||||
*two*
|
||||
</textarea>
|
||||
```
|
Loading…
Reference in a new issue