diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-06-12 09:16:05 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-06-12 09:23:30 +0200 |
commit | 8a000e3ecc330ff8a4953ebe8c7da9a54eca5c58 (patch) | |
tree | 6c05a38c8c31fc78bbbdc26cd3fec50c42c244cf | |
parent | b466152d6185750438f7355701ae68186692d65b (diff) | |
download | pandoc-8a000e3ecc330ff8a4953ebe8c7da9a54eca5c58.tar.gz |
Markdown writer: don't allow soft break in header.
Closes #3736.
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 7 | ||||
-rw-r--r-- | test/command/3736.md | 25 |
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 +-------- +``` |