aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-10-23 09:25:07 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-10-23 09:25:07 -0700
commitefc6994c8a792e72ae299bc33e18327c3c4acbc9 (patch)
tree0acfd24b745158c1cc095a11b000a5a8e1882983
parent0cd0627f02e1fe4a138861c5e83692c4fe2c85e0 (diff)
downloadpandoc-efc6994c8a792e72ae299bc33e18327c3c4acbc9.tar.gz
Commonmark writer: fix regression with fenced divs.
Starting with 2.10.1, fenced divs no longer render with HTML div tags in commonmark output. This is a regression due to our transition from cmark-gfm. This commit fixes it. Closes #6768.
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs4
-rw-r--r--test/command/6768.md21
2 files changed, 24 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 55f67b228..0aca83ad0 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -419,6 +419,7 @@ blockToMarkdown' :: PandocMonad m
blockToMarkdown' _ Null = return empty
blockToMarkdown' opts (Div attrs ils) = do
contents <- blockListToMarkdown opts ils
+ variant <- asks envVariant
return $
case () of
_ | isEnabled Ext_fenced_divs opts &&
@@ -428,7 +429,8 @@ blockToMarkdown' opts (Div attrs ils) = do
literal ":::" <> blankline
| isEnabled Ext_native_divs opts ||
(isEnabled Ext_raw_html opts &&
- isEnabled Ext_markdown_in_html_blocks opts) ->
+ (variant == Commonmark ||
+ isEnabled Ext_markdown_in_html_blocks opts)) ->
tagWithAttrs "div" attrs <> blankline <>
contents <> blankline <> "</div>" <> blankline
| isEnabled Ext_raw_html opts &&
diff --git a/test/command/6768.md b/test/command/6768.md
new file mode 100644
index 000000000..17a3ae878
--- /dev/null
+++ b/test/command/6768.md
@@ -0,0 +1,21 @@
+```
+% pandoc -tcommonmark
+::: custom_div
+This is a div
+:::
+^D
+<div class="custom_div">
+
+This is a div
+
+</div>
+```
+
+```
+% pandoc -tcommonmark-raw_html
+::: custom_div
+This is a div
+:::
+^D
+This is a div
+```