@@ -475,6 +475,8 @@ blockToMarkdown' opts (Header level attr inlines) = do
475 space <> attrsToMarkdown attr
475 space <> attrsToMarkdown attr
476 | otherwise -> empty
476 | otherwise -> empty
477 contents <- inlineListToMarkdown opts $
477 contents <- inlineListToMarkdown opts $
478+ -- ensure no newlines; see #3736
479+ walk lineBreakToSpace $
478 if level == 1 && plain
480 if level == 1 && plain
479 then capitalize inlines
481 then capitalize inlines
480 else inlines
482 else inlines
@@ -1203,3 +1205,8 @@ toSubscript c
1203 Just $ chr (0x2080 + (ord c - 48))
1205 Just $ chr (0x2080 + (ord c - 48))
1204 | isSpace c = Just c
1206 | isSpace c = Just c
1205 | otherwise = Nothing
1207 | otherwise = Nothing
1209+lineBreakToSpace :: Inline -> Inline
1210+lineBreakToSpace LineBreak = Space
1211+lineBreakToSpace SoftBreak = Space
1212+lineBreakToSpace x = x