commands: Add gen chromastyles --lineNumbersTableStyle flag

For symmetry, also rename --linesStyle to --lineNumbersInlineStyle.

Closes #12393
This commit is contained in:
Joe Mooring 2024-04-18 12:04:47 -07:00 committed by Bjørn Erik Pedersen
parent faf9fedc3d
commit da6112fc65
2 changed files with 18 additions and 11 deletions

View file

@ -45,9 +45,10 @@ func newGenCommand() *genCommand {
genmandir string genmandir string
// Chroma flags. // Chroma flags.
style string style string
highlightStyle string highlightStyle string
linesStyle string lineNumbersInlineStyle string
lineNumbersTableStyle string
) )
newChromaStyles := func() simplecobra.Commander { newChromaStyles := func() simplecobra.Commander {
@ -63,8 +64,11 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
if highlightStyle != "" { if highlightStyle != "" {
builder.Add(chroma.LineHighlight, highlightStyle) builder.Add(chroma.LineHighlight, highlightStyle)
} }
if linesStyle != "" { if lineNumbersInlineStyle != "" {
builder.Add(chroma.LineNumbers, linesStyle) builder.Add(chroma.LineNumbers, lineNumbersInlineStyle)
}
if lineNumbersTableStyle != "" {
builder.Add(chroma.LineNumbersTable, lineNumbersTableStyle)
} }
style, err := builder.Build() style, err := builder.Build()
if err != nil { if err != nil {
@ -80,8 +84,10 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
_ = cmd.RegisterFlagCompletionFunc("style", cobra.NoFileCompletions) _ = cmd.RegisterFlagCompletionFunc("style", cobra.NoFileCompletions)
cmd.PersistentFlags().StringVar(&highlightStyle, "highlightStyle", "", `foreground and background colors for highlighted lines, e.g. --highlightStyle "#fff000 bg:#000fff"`) cmd.PersistentFlags().StringVar(&highlightStyle, "highlightStyle", "", `foreground and background colors for highlighted lines, e.g. --highlightStyle "#fff000 bg:#000fff"`)
_ = cmd.RegisterFlagCompletionFunc("highlightStyle", cobra.NoFileCompletions) _ = cmd.RegisterFlagCompletionFunc("highlightStyle", cobra.NoFileCompletions)
cmd.PersistentFlags().StringVar(&linesStyle, "linesStyle", "", `foreground and background colors for inline line numbers, e.g. --linesStyle "#fff000 bg:#000fff"`) cmd.PersistentFlags().StringVar(&lineNumbersInlineStyle, "lineNumbersInlineStyle", "", `foreground and background colors for inline line numbers, e.g. --lineNumbersInlineStyle "#fff000 bg:#000fff"`)
_ = cmd.RegisterFlagCompletionFunc("linesStyle", cobra.NoFileCompletions) _ = cmd.RegisterFlagCompletionFunc("lineNumbersInlineStyle", cobra.NoFileCompletions)
cmd.PersistentFlags().StringVar(&lineNumbersTableStyle, "lineNumbersTableStyle", "", `foreground and background colors for table line numbers, e.g. --lineNumbersTableStyle "#fff000 bg:#000fff"`)
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
}, },
} }
} }

View file

@ -20,10 +20,11 @@ hugo gen chromastyles [flags] [args]
### Options ### Options
``` ```
-h, --help help for chromastyles -h, --help help for chromastyles
--highlightStyle string style used for highlighting lines (see https://github.com/alecthomas/chroma) --highlightStyle string foreground and background colors for highlighted lines, e.g. --highlightStyle "#fff000 bg:#000fff"
--linesStyle string style used for line numbers (see https://github.com/alecthomas/chroma) --lineNumbersInlineStyle string foreground and background colors for inline line numbers, e.g. --lineNumbersInlineStyle "#fff000 bg:#000fff"
--style string highlighter style (see https://xyproto.github.io/splash/docs/) (default "friendly") --lineNumbersTableStyle string foreground and background colors for table line numbers, e.g. --lineNumbersTableStyle "#fff000 bg:#000fff"
--style string highlighter style (see https://xyproto.github.io/splash/docs/) (default "friendly")
``` ```
### Options inherited from parent commands ### Options inherited from parent commands