Skip to content

Commit

Permalink
Pull in markdown parsing / rendering library
Browse files Browse the repository at this point in the history
  • Loading branch information
nint8835 committed Aug 24, 2023
1 parent 70e7050 commit c24a160
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
36 changes: 36 additions & 0 deletions cmd/example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cmd

import (
"bytes"
"fmt"

"github.com/spf13/cobra"
"github.com/yuin/goldmark"
)

var mdString = `# Almanac
This is some
- example
- markdown
- code
`

var exampleCmd = &cobra.Command{
Use: "example",
Short: "Example markdown rendering command",
RunE: func(cmd *cobra.Command, args []string) error {
var buf bytes.Buffer
if err := goldmark.Convert([]byte(mdString), &buf); err != nil {
return fmt.Errorf("failed to convert markdown: %w", err)
}

fmt.Println(buf.String())

return nil
},
}

func init() {
rootCmd.AddCommand(exampleCmd)
}
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module github.com/fogo-sh/almanac

go 1.21.0

require github.com/spf13/cobra v1.7.0
require (
github.com/spf13/cobra v1.7.0
github.com/yuin/goldmark v1.5.6
)

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/yuin/goldmark v1.5.6 h1:COmQAWTCcGetChm3Ig7G/t8AFAN00t+o8Mt4cf7JpwA=
github.com/yuin/goldmark v1.5.6/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit c24a160

Please sign in to comment.