git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: don't allow soft break in header.

Closes #3736.

commit8a000e3ecc330ff8a4953ebe8c7da9a54eca5c58 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 12 Jun 2017, 09:16 (9 years ago) parentb466152
2 files changed+32
src/Text/Pandoc/Writers/Markdown.hs+7 test/command/3736.md+25
src/Text/Pandoc/Writers/Markdown.hs+7
@@ -475,6 +475,8 @@ blockToMarkdown' opts (Header level attr inlines) = do
475475 space <> attrsToMarkdown attr
476476 | otherwise -> empty
477477 contents <- inlineListToMarkdown opts $
478+ -- ensure no newlines; see #3736
479+ walk lineBreakToSpace $
478480 if level == 1 && plain
479481 then capitalize inlines
480482 else inlines
@@ -1203,3 +1205,8 @@ toSubscript c
12031205 Just $ chr (0x2080 + (ord c - 48))
12041206 | isSpace c = Just c
12051207 | 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+```