From 6893b38a6e9e634c51d6dc789db03824feedb616 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger <285675+cscheid@users.noreply.github.com> Date: Sun, 27 Jul 2025 14:27:41 -0400 Subject: Markdown writer: use fenced divs even with empty attributes. Previously fenced divs were not used in this case, causing the writer to fall back to raw HTML. Closes #10955. --- src/Text/Pandoc/Writers/Markdown.hs | 3 +-- test/command/4164.md | 6 ++--- test/writer.markdown | 54 +++++++++++++------------------------ test/writer.opml | 2 +- 4 files changed, 22 insertions(+), 43 deletions(-) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index cd3e4ab91..476b54286 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -400,8 +400,7 @@ blockToMarkdown' opts (Div attrs@(_,classes,_) bs) | (take 3 (T.unpack id')) == "ref" -> contents <> blankline | otherwise -> contents <> blankline - | isEnabled Ext_fenced_divs opts && - attrs /= nullAttr -> + | isEnabled Ext_fenced_divs opts -> let attrsToMd = if variant == Commonmark then attrsToMarkdown opts else classOrAttrsToMarkdown opts diff --git a/test/command/4164.md b/test/command/4164.md index 4e7b7e285..e5cf5d98e 100644 --- a/test/command/4164.md +++ b/test/command/4164.md @@ -8,11 +8,9 @@ Here is inline html: -
- +::: {} ``{=html} bla bla - -
+::: ``` diff --git a/test/writer.markdown b/test/writer.markdown index 1ecb10679..0345da7a1 100644 --- a/test/writer.markdown +++ b/test/writer.markdown @@ -353,33 +353,23 @@ orange Simple block on one line: -
- +::: {} foo - -
+::: And nested without indentation: -
- -
- -
- +:::::: {} +:::: {} +::: {} foo +::: +:::: -
- -
- -
- +::: {} bar - -
- -
+::: +:::::: Interpreted markdown in a table: @@ -397,11 +387,9 @@ And this is **strong** Here's a simple block: -
- +::: {} foo - -
+::: This should be a code block, though: @@ -415,19 +403,13 @@ As should this: Now, nested: -
- -
- -
- +::::: {} +:::: {} +::: {} foo - -
- -
- -
+::: +:::: +::::: This should just be an HTML comment: diff --git a/test/writer.opml b/test/writer.opml index 89f4b6fee..b2fef8fc8 100644 --- a/test/writer.opml +++ b/test/writer.opml @@ -44,7 +44,7 @@ - + -- cgit v1.2.3