mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-14 07:07:33 -04:00
commands: Add --omitClassComments to the chromastyles command
This commit is contained in:
parent
cfc38ecfed
commit
c289fcaaaa
@ -51,6 +51,7 @@ func newGenCommand() *genCommand {
|
|||||||
lineNumbersInlineStyle string
|
lineNumbersInlineStyle string
|
||||||
lineNumbersTableStyle string
|
lineNumbersTableStyle string
|
||||||
omitEmpty bool
|
omitEmpty bool
|
||||||
|
omitClassComments bool
|
||||||
)
|
)
|
||||||
|
|
||||||
newChromaStyles := func() simplecobra.Commander {
|
newChromaStyles := func() simplecobra.Commander {
|
||||||
@ -81,12 +82,14 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var formatter *html.Formatter
|
var options []html.Option
|
||||||
if omitEmpty {
|
if omitEmpty {
|
||||||
formatter = html.New(html.WithClasses(true))
|
options = append(options, html.WithClasses(true))
|
||||||
} else {
|
} else {
|
||||||
formatter = html.New(html.WithAllClasses(true))
|
options = append(options, html.WithAllClasses(true))
|
||||||
}
|
}
|
||||||
|
options = append(options, html.WithCSSComments(!omitClassComments))
|
||||||
|
formatter := html.New(options...)
|
||||||
|
|
||||||
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:], " "))
|
||||||
@ -105,6 +108,8 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
|
|||||||
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
|
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
|
||||||
cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules`)
|
cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules`)
|
||||||
_ = cmd.RegisterFlagCompletionFunc("omitEmpty", cobra.NoFileCompletions)
|
_ = cmd.RegisterFlagCompletionFunc("omitEmpty", cobra.NoFileCompletions)
|
||||||
|
cmd.PersistentFlags().BoolVar(&omitClassComments, "omitClassComments", false, `omit CSS class comment prefixes in the generated CSS`)
|
||||||
|
_ = cmd.RegisterFlagCompletionFunc("omitClassComments", cobra.NoFileCompletions)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user