mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Calculate block width from BlockStack & RenderContext
This commit is contained in:
parent
58c97dc8db
commit
c31c06a793
1 changed files with 7 additions and 6 deletions
13
main.go
13
main.go
|
@ -110,18 +110,19 @@ func execute(cmd *cobra.Command, args []string) error {
|
|||
!cmd.Flags().Changed("style") {
|
||||
style = "notty"
|
||||
}
|
||||
r, err := gold.NewTermRenderer(style)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.WordWrap = int(width)
|
||||
|
||||
u, err := url.ParseRequestURI(src.URL)
|
||||
if err == nil {
|
||||
u.Path = filepath.Dir(u.Path)
|
||||
r.BaseURL = u.String() + "/"
|
||||
}
|
||||
|
||||
r, err := gold.NewTermRenderer(style, gold.Options{
|
||||
BaseURL: u.String() + "/",
|
||||
WordWrap: int(width),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out := r.RenderBytes(b)
|
||||
fmt.Printf("%s", string(out))
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue