From 43fb74760164368fd0c74c84e4f55ec3ab5d752e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 17 Apr 2023 17:20:59 -0700 Subject: [PATCH] Use .EX/.EE for code examples A pair of man macros named .EX and .EE are specifically created for things like code examples. This is ideally suited to typeset markdown code wrapped into ``` pairs. Add a simple test case. Signed-off-by: Kir Kolyshkin --- md2man/roff.go | 4 ++-- md2man/roff_test.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/md2man/roff.go b/md2man/roff.go index 073b793..9fd8edf 100644 --- a/md2man/roff.go +++ b/md2man/roff.go @@ -37,8 +37,8 @@ const ( linkCloseTag = "\\[ra]" codespanTag = "\\fB\\fC" codespanCloseTag = "\\fR" - codeTag = "\n.PP\n.RS\n\n.nf\n" - codeCloseTag = "\n.fi\n.RE\n" + codeTag = "\n.EX\n" + codeCloseTag = "\n.EE\n" 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 ecfb965..b31e809 100644 --- a/md2man/roff_test.go +++ b/md2man/roff_test.go @@ -10,6 +10,17 @@ type TestParams struct { extensions blackfriday.Extensions } +func TestCodeBlocks(t *testing.T) { + tests := []string{ + "```\nsome code\n```\n", + ".nh\n\n.EX\nsome code\n\n.EE\n", + + "```bash\necho foo\n```\n", + ".nh\n\n.EX\necho foo\n\n.EE\n", + } + doTestsParam(t, tests, TestParams{blackfriday.FencedCode}) +} + func TestEmphasis(t *testing.T) { var tests = []string{ "nothing inline\n",