glamour】 为命令行应用程序提供markdown的标记渲染【golang】


网址:https:github.com/charmbracelet/glamour

渲染效果

用法


import "github.com/charmbracelet/glamour"
  

  
in := `# Hello World
  

  
This is a simple example of Markdown rendering with Glamour!
  
Check out the [other examples](https://github.com/charmbracelet/glamour/tree/master/examples) too.
  

  
Bye!
  
`
  

  
out, err := glamour.Render(in, "dark")
  
fmt.Print(out)
  

样式

Dark

Light

NoTTY

自定义渲染器


import "github.com/charmbracelet/glamour"
  

  
r, _ := glamour.NewTermRenderer(
  
    // detect background color and pick either the default dark or light theme
  
    glamour.WithAutoStyle(),
  
    // wrap output at specific width
  
    glamour.WithWordWrap(40),
  
)
  

  
out, err := r.Render(in)
  
fmt.Print(out)
  

腾图小抄 SCWY.net v0.03 小抄561条 自2022-01-02访问365237次