Refactor HTMLFormat, update chroma render, fix js error (#33136)

A small refactor to improve HTMLFormat, to help to prevent low-level
mistakes.

And fix #33141, fix #33139
This commit is contained in:
wxiaoguang 2025-01-08 11:44:32 +08:00 committed by GitHub
parent 67aeb1f896
commit 386c1ed908
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 34 additions and 17 deletions

View file

@ -30,7 +30,7 @@ func ParseSizeAndClass(defaultSize int, defaultClass string, others ...any) (int
return size, class
}
func HTMLFormat(s string, rawArgs ...any) template.HTML {
func HTMLFormat(s template.HTML, rawArgs ...any) template.HTML {
args := slices.Clone(rawArgs)
for i, v := range args {
switch v := v.(type) {
@ -44,5 +44,5 @@ func HTMLFormat(s string, rawArgs ...any) template.HTML {
args[i] = template.HTMLEscapeString(fmt.Sprint(v))
}
}
return template.HTML(fmt.Sprintf(s, args...))
return template.HTML(fmt.Sprintf(string(s), args...))
}