internal/nixdocs/command/example/main.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | package main
import (
"bytes"
"fmt"
"os"
"alin.ovh/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())
}
|