mirror of
https://github.com/charmbracelet/gum
synced 2026-03-14 21:55:45 +01:00
Merge 1af591f6b6 into 06d72ec646
This commit is contained in:
commit
2a0e2fa5cb
2 changed files with 15 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/charmbracelet/bubbles/help"
|
||||
"github.com/charmbracelet/bubbles/viewport"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/glamour"
|
||||
"github.com/charmbracelet/gum/internal/stdin"
|
||||
"github.com/charmbracelet/gum/internal/timeout"
|
||||
)
|
||||
|
|
@ -31,6 +32,19 @@ func (o Options) Run() error {
|
|||
}
|
||||
}
|
||||
|
||||
if o.SyntaxHighlight != "" {
|
||||
switch {
|
||||
case o.SyntaxHighlight == "markdown":
|
||||
renderedContent, err := glamour.Render(o.Content, "dark")
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to render: %w", err)
|
||||
}
|
||||
o.Content = renderedContent
|
||||
default:
|
||||
return fmt.Errorf("syntax-highlight language: markdown")
|
||||
}
|
||||
}
|
||||
|
||||
m := model{
|
||||
viewport: vp,
|
||||
help: help.New(),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
type Options struct {
|
||||
//nolint:staticcheck
|
||||
Style style.Styles `embed:"" help:"Style the pager" set:"defaultBorder=rounded" set:"defaultPadding=0 1" set:"defaultBorderForeground=212" envprefix:"GUM_PAGER_"`
|
||||
SyntaxHighlight string `help:"syntax highlighting (support language: markdown)" default:""`
|
||||
Content string `arg:"" optional:"" help:"Display content to scroll"`
|
||||
ShowLineNumbers bool `help:"Show line numbers" default:"true"`
|
||||
LineNumberStyle style.Styles `embed:"" prefix:"line-number." help:"Style the line numbers" set:"defaultForeground=237" envprefix:"GUM_PAGER_LINE_NUMBER_"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue