Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type Config struct {
Height float64 `json:"height" help:"Height of terminal window." short:"H" group:"Window"`

// Settings
Config string `json:"config,omitempty" help:"Base configuration file or template." short:"c" group:"Settings" default:"default" placeholder:"base"`
Interactive bool `hidden:"" json:",omitempty" help:"Use an interactive form for configuration options." short:"i" group:"Settings"`
Language string `json:"language,omitempty" help:"Language of code file." short:"l" group:"Settings" placeholder:"go"`
Theme string `json:"theme" help:"Theme to use for syntax highlighting." short:"t" group:"Settings" placeholder:"charm"`
Config string `json:"config,omitempty" help:"Base configuration file or template." short:"c" group:"Settings" default:"default" placeholder:"base"`
Interactive bool `hidden:"" json:",omitempty" help:"Use an interactive form for configuration options." short:"i" group:"Settings"`
Language []string `json:"language,omitempty" help:"Language of code file." short:"l" group:"Settings" placeholder:"go"`
Theme string `json:"theme" help:"Theme to use for syntax highlighting." short:"t" group:"Settings" placeholder:"charm"`

Output string `json:"output,omitempty" help:"Output location for {{.svg}}, {{.png}}, or {{.webp}}." short:"o" group:"Settings" default:"" placeholder:"freeze.svg"`
Execute string `json:"-" help:"Capture output of command execution." short:"x" group:"Settings" default:""`
Expand Down
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func main() {
input, err = in.ReadInput(os.Stdin)
lexer = lexers.Analyse(input)
} else if config.Execute != "" {
config.Language = "ansi"
config.Language[0] = "ansi"
} else {
input, err = in.ReadFile(config.Input)
if err != nil {
Expand All @@ -159,8 +159,12 @@ func main() {
lexer = lexers.Get(config.Input)
}

if config.Language != "" {
lexer = lexers.Get(config.Language)
if config.Language[0] != "" && len(config.Language) == 1 {
lexer = lexers.Get(config.Language[0])
} else if len(config.Language) == 2 {
language := lexers.Get(config.Language[0])
root := lexers.Get(config.Language[1])
lexer = chroma.DelegatingLexer(root, language)
}

// adjust for 1-indexing
Expand All @@ -169,7 +173,7 @@ func main() {
}

var strippedInput string = ansi.Strip(input)
isAnsi := strings.ToLower(config.Language) == "ansi" || strippedInput != input
isAnsi := strings.ToLower(config.Language[0]) == "ansi" || strippedInput != input
strippedInput = cut(strippedInput, config.Lines)

if !isAnsi && lexer == nil {
Expand Down