aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-12-11 11:30:38 +0100
committerJohn MacFarlane <[email protected]>2025-12-11 11:30:38 +0100
commit1f76d3f1547c410d06db68007dd5aead8e75834d (patch)
tree2db3b1ff560e4b3d01ada9d540320f049c4bdebb /src
parent6d745e52767d1a1595d19b1950f41f4eaef5145f (diff)
Markdown writer: use setext for headers containing line breaks...
...for commonmark. Closes #11341.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 1750db3bd..ee5463a1e 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -529,15 +529,19 @@ blockToMarkdown' opts (Header level attr inlines) = do
isEnabled Ext_attributes opts ->
space <> attrsToMarkdown opts attr
| otherwise -> empty
+ let setext = level <= 2 && writerSetextHeaders opts ||
+ (variant == Commonmark &&
+ hasLineBreaks inlines) -- #11341
contents <- inlineListToMarkdown opts $
- -- ensure no newlines; see #3736
- walk lineBreakToSpace $
+ (if variant == Commonmark && setext
+ then id
+ else -- ensure no newlines; see #3736
+ walk lineBreakToSpace) $
if level == 1 && variant == PlainText &&
isEnabled Ext_gutenberg opts
then capitalize inlines
else inlines
- let setext = writerSetextHeaders opts
when (not setext && isEnabled Ext_literate_haskell opts) $
report $ ATXHeadingInLHS level (render Nothing contents)