package filepath import ( "bytes" "testing" "github.com/yuin/goldmark" ) func TestFilePathExtension(t *testing.T) { markdown := goldmark.New( goldmark.WithExtensions( New(), ), ) tests := []struct { name string input string expected string }{ { name: "basic file path reference", input: "{file}`/etc/passwd`", expected: "
/etc/passwd
\n", }, { name: "file path reference in sentence", input: "The configuration file {file}`/etc/fstab` contains file system information.", expected: "The configuration file /etc/fstab" + " contains file system information.
\n", }, { name: "multiple file path references", input: "Both {file}`/etc/hosts` and {file}`/etc/resolv.conf` define DNS settings.", expected: "Both /etc/hosts and " + "/etc/resolv.conf define DNS settings.
\n", }, { name: "incomplete file path reference - no closing backtick", input: "{file}`/missing/backtick", expected: "{file}`/missing/backtick
\n", }, { name: "incomplete file path reference - empty path", input: "{file}``", expected: "{file}``
\n", }, { name: "file path reference with code block", input: "Edit {file}`~/.bashrc` using your favorite `text editor`.", expected: "Edit ~/.bashrc " +
"using your favorite text editor
.