Skip to content

Commit 61ec7a2

Browse files
committed
commands: Deprecate --omitEmpty on chromastyles command
It's no longer needed -- empty classes are now always omitted. See See alecthomas/chroma@5b2a4c5
1 parent c289fca commit 61ec7a2

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

commands/gen.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
8282
return err
8383
}
8484

85-
var options []html.Option
8685
if omitEmpty {
87-
options = append(options, html.WithClasses(true))
88-
} else {
89-
options = append(options, html.WithAllClasses(true))
86+
// See https://github.com/alecthomas/chroma/commit/5b2a4c5a26c503c79bc86ba3c4ae5b330028bd3d
87+
hugo.Deprecate("--omitEmpty", "Flag is no longer needed, empty classes are now always omitted.", "v0.149.0")
88+
}
89+
options := []html.Option{
90+
html.WithCSSComments(!omitClassComments),
9091
}
91-
options = append(options, html.WithCSSComments(!omitClassComments))
9292
formatter := html.New(options...)
9393

9494
w := os.Stdout
@@ -106,7 +106,7 @@ See https://xyproto.github.io/splash/docs/all.html for a preview of the availabl
106106
_ = cmd.RegisterFlagCompletionFunc("lineNumbersInlineStyle", cobra.NoFileCompletions)
107107
cmd.PersistentFlags().StringVar(&lineNumbersTableStyle, "lineNumbersTableStyle", "", `foreground and background colors for table line numbers, e.g. --lineNumbersTableStyle "#fff000 bg:#000fff"`)
108108
_ = cmd.RegisterFlagCompletionFunc("lineNumbersTableStyle", cobra.NoFileCompletions)
109-
cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules`)
109+
cmd.PersistentFlags().BoolVar(&omitEmpty, "omitEmpty", false, `omit empty CSS rules (deprecated, no longer needed)`)
110110
_ = cmd.RegisterFlagCompletionFunc("omitEmpty", cobra.NoFileCompletions)
111111
cmd.PersistentFlags().BoolVar(&omitClassComments, "omitClassComments", false, `omit CSS class comment prefixes in the generated CSS`)
112112
_ = cmd.RegisterFlagCompletionFunc("omitClassComments", cobra.NoFileCompletions)

testscripts/commands/gen.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ stdout 'Generated using: hugo gen chromastyles --style monokai'
1515
! hugo gen chromastyles --style __invalid_style__
1616
stderr 'invalid style: __invalid_style__'
1717

18-
# Issue 13475
18+
# Not empty classes.
19+
# From Hugo 0.149.0 empty classes are always removed, so no need for the omitEmpty flag.
1920
hugo gen chromastyles --style monokai
20-
stdout '{ }'
21-
hugo gen chromastyles --omitEmpty --style monokai
22-
! stdout '\{ \}'
21+
! stdout '{ }'
22+
hugo gen chromastyles --omitEmpty --style monokai --logLevel info
23+
stderr 'INFO deprecated: --omitEmpty was deprecated'
24+
25+
# Disable class comments.
26+
hugo gen chromastyles --style monokai
27+
stdout 'GenericSubheading'
28+
hugo gen chromastyles --omitClassComments --style monokai
29+
! stdout 'GenericSubheading'

0 commit comments

Comments
 (0)