diff options
| author | John MacFarlane <[email protected]> | 2025-12-11 11:30:38 +0100 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-12-11 11:30:38 +0100 |
| commit | 1f76d3f1547c410d06db68007dd5aead8e75834d (patch) | |
| tree | 2db3b1ff560e4b3d01ada9d540320f049c4bdebb /src | |
| parent | 6d745e52767d1a1595d19b1950f41f4eaef5145f (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.hs | 10 |
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) |
