git.iko.soy/typeable/pandoc
on master help sign in
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.

commitefc6994c8a792e72ae299bc33e18327c3c4acbc9 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 23 Oct 2020, 09:25 (6 years ago) parent0cd0627
2 files changed+24−1
src/Text/Pandoc/Writers/Markdown.hs+3−1 test/command/6768.md+21
src/Text/Pandoc/Writers/Markdown.hs+3−1
@@ -419,6 +419,7 @@ blockToMarkdown' :: PandocMonad m
419419blockToMarkdown' _ Null = return empty
420420blockToMarkdown' opts (Div attrs ils) = do
421421 contents <- blockListToMarkdown opts ils
422+ variant <- asks envVariant
422423 return $
423424 case () of
424425 _ | isEnabled Ext_fenced_divs opts &&
@@ -428,7 +429,8 @@ blockToMarkdown' opts (Div attrs ils) = do
428429 literal ":::" <> blankline
429430 | isEnabled Ext_native_divs opts ||
430431 (isEnabled Ext_raw_html opts &&
431− isEnabled Ext_markdown_in_html_blocks opts) ->
432+ (variant == Commonmark ||
433+ isEnabled Ext_markdown_in_html_blocks opts)) ->
432434 tagWithAttrs "div" attrs <> blankline <>
433435 contents <> blankline <> "</div>" <> blankline
434436 | isEnabled Ext_raw_html opts &&
test/command/6768.mdnew file+21
@@ -0,0 +1,21 @@
1+```
2+% pandoc -tcommonmark
3+::: custom_div
4+This is a div
5+:::
6+^D
7+<div class="custom_div">
8+
9+This is a div
10+
11+</div>
12+```
13+
14+```
15+% pandoc -tcommonmark-raw_html
16+::: custom_div
17+This is a div
18+:::
19+^D
20+This is a div
21+```