all repos — searchix @ cb907ad36521036db199a226f3e357ad3b7b0a1c

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: parse {command} in markdown documentation

Alan Pearce
commit

cb907ad36521036db199a226f3e357ad3b7b0a1c

parent

0ba69e50d2d1095db9b42c548c0226739d137a62

1 file changed, 35 insertions(+), 0 deletions(-)

changed files
A internal/nixdocs/command/example/main.go
@@ -0,0 +1,35 @@
+package main + +import ( + "bytes" + "fmt" + "os" + + "go.alanpearce.eu/searchix/internal/nixdocs/command" + + "github.com/yuin/goldmark" +) + +func main() { + // Create a new markdown parser with the command extension + md := goldmark.New( + goldmark.WithExtensions( + command.New(), + ), + ) + + // Example markdown text with command references + markdown := "Use {command}`git clone git@github.com:example/repo.git` to clone the repository." + + // Convert markdown to HTML + var buf bytes.Buffer + if err := md.Convert([]byte(markdown), &buf); err != nil { + fmt.Fprintf(os.Stderr, "Error converting markdown: %v\n", err) + os.Exit(1) + } + + // Print the resulting HTML + fmt.Println("HTML Output:") + fmt.Println("===========") + fmt.Println(buf.String()) +}