]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
commands: Deprecate --omitEmpty on chromastyles command
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 25 Aug 2025 14:21:30 +0000 (16:21 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 25 Aug 2025 16:24:07 +0000 (18:24 +0200)
It's no longer needed -- empty classes are now always omitted.

See  See https://github.com/alecthomas/chroma/commit/5b2a4c5a26c503c79bc86ba3c4ae5b330028bd3d

commands/gen.go
testscripts/commands/gen.txt

index 8e7e6a380a10d1a59fff351ecd1c5dad1d509bbd..5a5affe9e386628943bdbd15d601fc9b0be421bb 100644 (file)
@@ -82,13 +82,13 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
                                        return err
                                }
 
-                               var options []html.Option
                                if omitEmpty {
-                                       options = append(options, html.WithClasses(true))
-                               } else {
-                                       options = append(options, html.WithAllClasses(true))
+                                       // See https://github.com/alecthomas/chroma/commit/5b2a4c5a26c503c79bc86ba3c4ae5b330028bd3d
+                                       hugo.Deprecate("--omitEmpty", "Flag is no longer needed, empty classes are now always omitted.", "v0.149.0")
+                               }
+                               options := []html.Option{
+                                       html.WithCSSComments(!omitClassComments),
                                }
-                               options = append(options, html.WithCSSComments(!omitClassComments))
                                formatter := html.New(options...)
 
                                w := os.Stdout
@@ -106,7 +106,7 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
                                _ = 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)
-                               cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules`)
+                               cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules (deprecated, no longer needed)`)
                                _ = 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)
index e83e9982f9f414b930bb0cdb923534f04b02be5a..d0aff93c1fd11f89f4a651cf72df3247947d28bd 100644 (file)
@@ -15,8 +15,15 @@ stdout 'Generated using: hugo gen chromastyles --style monokai'
 ! hugo gen chromastyles --style __invalid_style__
 stderr 'invalid style: __invalid_style__'
 
-# Issue 13475
+# Not empty classes.
+# From Hugo 0.149.0 empty classes are always removed, so no need for the omitEmpty flag.
 hugo gen chromastyles --style monokai
-stdout '{  }'
-hugo gen chromastyles --omitEmpty --style monokai
-! stdout '\{  \}'
+! stdout '{  }'
+hugo gen chromastyles --omitEmpty --style monokai --logLevel info
+stderr 'INFO  deprecated: --omitEmpty was deprecated'
+
+# Disable class comments.
+hugo gen chromastyles --style monokai
+stdout 'GenericSubheading'
+hugo gen chromastyles --omitClassComments --style monokai
+! stdout 'GenericSubheading'
\ No newline at end of file