mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 06:30:33 +03:00
parent
eebea9ec41
commit
93df17661f
2 changed files with 17 additions and 1 deletions
|
@ -50,6 +50,7 @@ func newGenCommand() *genCommand {
|
||||||
highlightStyle string
|
highlightStyle string
|
||||||
lineNumbersInlineStyle string
|
lineNumbersInlineStyle string
|
||||||
lineNumbersTableStyle string
|
lineNumbersTableStyle string
|
||||||
|
omitEmpty bool
|
||||||
)
|
)
|
||||||
|
|
||||||
newChromaStyles := func() simplecobra.Commander {
|
newChromaStyles := func() simplecobra.Commander {
|
||||||
|
@ -79,7 +80,14 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
formatter := html.New(html.WithAllClasses(true))
|
|
||||||
|
var formatter *html.Formatter
|
||||||
|
if omitEmpty {
|
||||||
|
formatter = html.New(html.WithClasses(true))
|
||||||
|
} else {
|
||||||
|
formatter = html.New(html.WithAllClasses(true))
|
||||||
|
}
|
||||||
|
|
||||||
w := os.Stdout
|
w := os.Stdout
|
||||||
fmt.Fprintf(w, "/* Generated using: hugo %s */\n\n", strings.Join(os.Args[1:], " "))
|
fmt.Fprintf(w, "/* Generated using: hugo %s */\n\n", strings.Join(os.Args[1:], " "))
|
||||||
formatter.WriteCSS(w, style)
|
formatter.WriteCSS(w, style)
|
||||||
|
@ -95,6 +103,8 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
|
||||||
_ = cmd.RegisterFlagCompletionFunc("lineNumbersInlineStyle", 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.PersistentFlags().StringVar(&lineNumbersTableStyle, "lineNumbersTableStyle", "", `foreground and background colors for table line numbers, e.g. --lineNumbersTableStyle "#fff000 bg:#000fff"`)
|
||||||
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
|
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
|
||||||
|
cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules`)
|
||||||
|
_ = cmd.RegisterFlagCompletionFunc("omitEmpty", cobra.NoFileCompletions)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,3 +14,9 @@ hugo gen chromastyles --style monokai
|
||||||
stdout 'Generated using: hugo gen chromastyles --style monokai'
|
stdout 'Generated using: hugo gen chromastyles --style monokai'
|
||||||
! hugo gen chromastyles --style __invalid_style__
|
! hugo gen chromastyles --style __invalid_style__
|
||||||
stderr 'invalid style: __invalid_style__'
|
stderr 'invalid style: __invalid_style__'
|
||||||
|
|
||||||
|
# Issue 13475
|
||||||
|
hugo gen chromastyles --style monokai
|
||||||
|
stdout '{ }'
|
||||||
|
hugo gen chromastyles --omitEmpty --style monokai
|
||||||
|
! stdout '\{ \}'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue