Add example using a custom glamour renderer

This commit is contained in:
Christian Muehlhaeuser
2019-12-25 04:53:34 +01:00
parent 621a573d6f
commit c17201aa04
2 changed files with 52 additions and 0 deletions
+26
View File
@@ -28,6 +28,32 @@ fmt.Printf(out)
![HelloWorld Example](https://github.com/charmbracelet/glamour/raw/master/examples/helloworld/helloworld.png)
### Custom Renderer
```go
import (
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/glamour/ansi"
)
in := `# Custom Renderer
Word-wrapping will occur when lines exceed the limit of 40 characters. Just so
you know: Glamour's default word-wrapping limit is set to 100 characters per
line.
Bye!
`
r, _ := glamour.NewTermRenderer("dark", ansi.Options{
WordWrap: int(40),
})
out, _ := r.Render(in)
fmt.Printf("%s", out)
}
```
## Glamourous Projects
+26
View File
@@ -0,0 +1,26 @@
package main
import (
"fmt"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/glamour/ansi"
)
func main() {
in := `# Custom Renderer
Word-wrapping will occur when lines exceed the limit of 40 characters. Just so
you know: Glamour's default word-wrapping limit is set to 100 characters per
line.
Bye!
`
r, _ := glamour.NewTermRenderer("dark", ansi.Options{
WordWrap: int(40),
})
out, _ := r.Render(in)
fmt.Printf("%s", out)
}