Skip to content

Commit 429ca76

Browse files
committed
commands: Add --omitClassComments to the chromastyles command
1 parent 2e1e718 commit 429ca76

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

commands/gen.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func newGenCommand() *genCommand {
5151
lineNumbersInlineStyle string
5252
lineNumbersTableStyle string
5353
omitEmpty bool
54+
omitClassComments bool
5455
)
5556

5657
newChromaStyles := func() simplecobra.Commander {
@@ -81,12 +82,14 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
8182
return err
8283
}
8384

84-
var formatter *html.Formatter
85+
var options []html.Option
8586
if omitEmpty {
86-
formatter = html.New(html.WithClasses(true))
87+
options = append(options, html.WithClasses(true))
8788
} else {
88-
formatter = html.New(html.WithAllClasses(true))
89+
options = append(options, html.WithAllClasses(true))
8990
}
91+
options = append(options, html.WithCSSComments(!omitClassComments))
92+
formatter := html.New(options...)
9093

9194
w := os.Stdout
9295
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
105108
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
106109
cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules`)
107110
_ = cmd.RegisterFlagCompletionFunc("omitEmpty", cobra.NoFileCompletions)
111+
cmd.PersistentFlags().BoolVar(&omitClassComments, "omitClassComments", false, `omit CSS class comment prefixes in the generated CSS`)
112+
_ = cmd.RegisterFlagCompletionFunc("omitClassComments", cobra.NoFileCompletions)
108113
},
109114
}
110115
}

0 commit comments

Comments
 (0)