diff options
| author | John MacFarlane <[email protected]> | 2024-12-22 10:46:39 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-12-22 10:47:30 -0800 |
| commit | d9281d1eaf5e52f8bad383eb36af02168555e91a (patch) | |
| tree | ba2e202a1b3db918be6c4b47238e0089d0a3e4dc /src | |
| parent | d064ad77a57c77c11c3564a8ff438f549c9a386a (diff) | |
Markdown writer: avoid collapsing of initial/final newline in...
...markdown raw blocks. For motivation see #10477.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 9a9cf29b7..57d61be42 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -470,16 +470,18 @@ blockToMarkdown' opts b@(RawBlock f str) = do let renderEmpty = mempty <$ report (BlockNotRendered b) case variant of PlainText - | f == "plain" -> return $ literal str <> literal "\n" + | f == "plain" -> return $ nest 0 (literal str) <> literal "\n" Commonmark | f `elem` ["gfm", "commonmark", "commonmark_x", "markdown"] - -> return $ literal str $$ blankline + -> return $ nest 0 (literal str) $$ blankline | f `elem` ["html", "html5", "html4"] -> return $ literal (removeBlankLinesInHTML str) $$ blankline Markdown | f `elem` ["markdown", "markdown_github", "markdown_phpextra", "markdown_mmd", "markdown_strict"] - -> return $ literal str <> literal "\n" + -- the 'nest 0' ensures that leading and trailing newlines + -- don't get collapsed. See #10477 for context; + -> return $ nest 0 (literal str) <> literal "\n" Markua -> renderEmpty _ | f `elem` ["html", "html5", "html4"] , isEnabled Ext_markdown_attribute opts |
