git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: don't allow soft break in header.
8a000e3John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+7
@@ -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
1208+
1209+lineBreakToSpace :: Inline -> Inline
1210+lineBreakToSpace LineBreak = Space
1211+lineBreakToSpace SoftBreak = Space
1212+lineBreakToSpace x = x
test/command/3736.mdnew file+25
@@ -0,0 +1,25 @@
1+```
2+% pandoc --wrap=preserve -f html -t markdown
3+<h2>hi
4+there</h2>
5+^D
6+hi there
7+--------
8+```
9+
10+```
11+% pandoc --wrap=preserve -f html -t markdown
12+<h2>hi <em>there
13+again</em></h2>
14+^D
15+hi *there again*
16+----------------
17+```
18+
19+```
20+% pandoc --wrap=preserve -f html -t markdown
21+<h2>hi<br>there</h2>
22+^D
23+hi there
24+--------
25+```