Skip to content

Commit

Permalink
Use .EX/.EE for code examples
Browse files Browse the repository at this point in the history
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 <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Apr 18, 2023
1 parent 6aaabf8 commit 43fb747
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions md2man/roff.go
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions md2man/roff_test.go
Expand Up @@ -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",
Expand Down

0 comments on commit 43fb747

Please sign in to comment.