diff --git a/md2man/roff.go b/md2man/roff.go index 4b19188..3707581 100644 --- a/md2man/roff.go +++ b/md2man/roff.go @@ -38,7 +38,7 @@ const ( codespanTag = "\\fB" codespanCloseTag = "\\fR" codeTag = "\n.EX\n" - codeCloseTag = "\n.EE\n" + codeCloseTag = ".EE\n" // Do not being this with `\n` since it will already be included in the code block quoteTag = "\n.PP\n.RS\n" quoteCloseTag = "\n.RE\n" listTag = "\n.RS\n" diff --git a/md2man/roff_test.go b/md2man/roff_test.go index af03326..0270d0d 100644 --- a/md2man/roff_test.go +++ b/md2man/roff_test.go @@ -13,10 +13,14 @@ type TestParams struct { func TestCodeBlocks(t *testing.T) { tests := []string{ "```\nsome code\n```\n", - ".nh\n\n.EX\nsome code\n\n.EE\n", + ".nh\n\n.EX\nsome code\n.EE\n", "```bash\necho foo\n```\n", - ".nh\n\n.EX\necho foo\n\n.EE\n", + ".nh\n\n.EX\necho foo\n.EE\n", + + // make sure we litteral new lines surrounding in the markdown block are preserved as they are intentional + "```bash\n\nsome code\n\n```", + ".nh\n\n.EX\n\nsome code\n\n.EE\n", } doTestsParam(t, tests, TestParams{blackfriday.FencedCode}) }