mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-22 08:04:18 +02:00
Remove blackfriday requirement from clients
This commit is contained in:
parent
985a7e5178
commit
218aff99ae
2 changed files with 13 additions and 3 deletions
|
|
@ -7,7 +7,6 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/magicnumbers/gold"
|
||||
bf "gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -25,11 +24,10 @@ func main() {
|
|||
}
|
||||
defer f.Close()
|
||||
b, _ := ioutil.ReadAll(f)
|
||||
r, err := gold.NewTermRenderer(*s)
|
||||
out, err := gold.RenderBytes(b, *s)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
out := bf.Run(b, bf.WithRenderer(r))
|
||||
fmt.Printf("%s", string(out))
|
||||
}
|
||||
|
|
|
|||
12
gold.go
12
gold.go
|
|
@ -209,6 +209,18 @@ func NewElement(node *bf.Node) Element {
|
|||
|
||||
}
|
||||
|
||||
func Render(in string, stylePath string) ([]byte, error) {
|
||||
return RenderBytes([]byte(in), stylePath)
|
||||
}
|
||||
|
||||
func RenderBytes(in []byte, stylePath string) ([]byte, error) {
|
||||
r, err := NewTermRenderer(stylePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bf.Run(in, bf.WithRenderer(r)), nil
|
||||
}
|
||||
|
||||
func NewTermRenderer(stylePath string) (*TermRenderer, error) {
|
||||
if stylePath == "" {
|
||||
return NewTermRendererFromBytes([]byte("{}"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue