package manpage import ( "bytes" "testing" "github.com/yuin/goldmark" ) func TestManPageExtension(t *testing.T) { markdown := goldmark.New( goldmark.WithExtensions( New(), ), ) tests := []struct { name string input string expected string }{ { name: "basic manpage reference", input: "{manpage}`nix.conf(5)`", expected: "
\n", }, { name: "manpage reference in sentence", input: "See {manpage}`git(1)` for more information.", expected: "See git(1) for more information.
\n", }, { name: "multiple manpage references", input: "Both {manpage}`ssh(1)` and {manpage}`sshd(8)` have configuration options.", expected: "Both ssh(1) and " + "sshd(8) have configuration options.
\n", }, { name: "incomplete manpage reference - no closing backtick", input: "{manpage}`missing.backtick", expected: "{manpage}`missing.backtick
\n", }, { name: "incomplete manpage reference - empty reference", input: "{manpage}``", expected: "{manpage}``
\n", }, { name: "invalid manpage reference - no section", input: "{manpage}`nixos`", expected: "nixos
\n", }, { name: "invalid manpage reference - invalid section format", input: "{manpage}`bash(x)`", expected: "bash(x)
\n", }, { name: "manpage reference with code block", input: "Configure {manpage}`httpd.conf(5)` in your `apache` directory.", expected: "Configure httpd.conf(5) " +
"in your apache
directory.