Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/log"
gap "github.com/muesli/go-app-paths"
"github.com/muesli/termenv"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/term"
Expand Down Expand Up @@ -208,6 +209,19 @@ func validateOptions(cmd *cobra.Command) error {
return nil
}

func chromaFormatter(p termenv.Profile) string {
switch p {
case termenv.TrueColor:
return "terminal16m"
case termenv.ANSI256:
return "terminal256"
case termenv.ANSI:
return "terminal16"
default:
return "terminal"
}
}

func stdinIsPipe() (bool, error) {
stat, err := os.Stdin.Stat()
if err != nil {
Expand Down Expand Up @@ -289,8 +303,10 @@ func executeCLI(cmd *cobra.Command, src *source, w io.Writer) error {
isCode := !utils.IsMarkdownFile(src.URL)

// initialize glamour
colorProfile := lipgloss.ColorProfile()
r, err := glamour.NewTermRenderer(
glamour.WithColorProfile(lipgloss.ColorProfile()),
glamour.WithColorProfile(colorProfile),
glamour.WithChromaFormatter(chromaFormatter(colorProfile)),
utils.GlamourStyle(style, isCode),
glamour.WithWordWrap(int(width)), //nolint:gosec
glamour.WithBaseURL(baseURL),
Expand Down