Skip to content

Commit

Permalink
Markdown writer: avoid collapsing of initial/final newline in...
Browse files Browse the repository at this point in the history
...markdown raw blocks.  For motivation see #10477.
  • Loading branch information
jgm committed Dec 22, 2024
1 parent d064ad7 commit d9281d1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Text/Pandoc/Writers/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9281d1

Please sign in to comment.