aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs7
-rw-r--r--test/command/3736.md25
2 files changed, 32 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 69243a214..3ac677943 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -475,6 +475,8 @@ blockToMarkdown' opts (Header level attr inlines) = do
space <> attrsToMarkdown attr
| otherwise -> empty
contents <- inlineListToMarkdown opts $
+ -- ensure no newlines; see #3736
+ walk lineBreakToSpace $
if level == 1 && plain
then capitalize inlines
else inlines
@@ -1203,3 +1205,8 @@ toSubscript c
Just $ chr (0x2080 + (ord c - 48))
| isSpace c = Just c
| otherwise = Nothing
+
+lineBreakToSpace :: Inline -> Inline
+lineBreakToSpace LineBreak = Space
+lineBreakToSpace SoftBreak = Space
+lineBreakToSpace x = x
diff --git a/test/command/3736.md b/test/command/3736.md
new file mode 100644
index 000000000..b66e0a359
--- /dev/null
+++ b/test/command/3736.md
@@ -0,0 +1,25 @@
+```
+% pandoc --wrap=preserve -f html -t markdown
+<h2>hi
+there</h2>
+^D
+hi there
+--------
+```
+
+```
+% pandoc --wrap=preserve -f html -t markdown
+<h2>hi <em>there
+again</em></h2>
+^D
+hi *there again*
+----------------
+```
+
+```
+% pandoc --wrap=preserve -f html -t markdown
+<h2>hi<br>there</h2>
+^D
+hi there
+--------
+```