mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
@@ -115,12 +115,12 @@ func (cfg Config) ToHTMLOptions() []html.Option {
|
||||
return options
|
||||
}
|
||||
|
||||
func applyOptions(opts interface{}, cfg *Config) error {
|
||||
func applyOptions(opts any, cfg *Config) error {
|
||||
if opts == nil {
|
||||
return nil
|
||||
}
|
||||
switch vv := opts.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
return applyOptionsFromMap(vv, cfg)
|
||||
default:
|
||||
s, err := cast.ToStringE(opts)
|
||||
@@ -139,7 +139,7 @@ func applyOptionsFromString(opts string, cfg *Config) error {
|
||||
return mapstructure.WeakDecode(optsm, cfg)
|
||||
}
|
||||
|
||||
func applyOptionsFromMap(optsm map[string]interface{}, cfg *Config) error {
|
||||
func applyOptionsFromMap(optsm map[string]any, cfg *Config) error {
|
||||
normalizeHighlightOptions(optsm)
|
||||
return mapstructure.WeakDecode(optsm, cfg)
|
||||
}
|
||||
@@ -184,9 +184,9 @@ func ApplyLegacyConfig(cfg config.Provider, conf *Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseHightlightOptions(in string) (map[string]interface{}, error) {
|
||||
func parseHightlightOptions(in string) (map[string]any, error) {
|
||||
in = strings.Trim(in, " ")
|
||||
opts := make(map[string]interface{})
|
||||
opts := make(map[string]any)
|
||||
|
||||
if in == "" {
|
||||
return opts, nil
|
||||
@@ -207,7 +207,7 @@ func parseHightlightOptions(in string) (map[string]interface{}, error) {
|
||||
return opts, nil
|
||||
}
|
||||
|
||||
func normalizeHighlightOptions(m map[string]interface{}) {
|
||||
func normalizeHighlightOptions(m map[string]any) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
|
@@ -58,8 +58,8 @@ func New(cfg Config) Highlighter {
|
||||
}
|
||||
|
||||
type Highlighter interface {
|
||||
Highlight(code, lang string, opts interface{}) (string, error)
|
||||
HighlightCodeBlock(ctx hooks.CodeblockContext, opts interface{}) (HightlightResult, error)
|
||||
Highlight(code, lang string, opts any) (string, error)
|
||||
HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HightlightResult, error)
|
||||
hooks.CodeBlockRenderer
|
||||
hooks.IsDefaultCodeBlockRendererProvider
|
||||
}
|
||||
@@ -68,7 +68,7 @@ type chromaHighlighter struct {
|
||||
cfg Config
|
||||
}
|
||||
|
||||
func (h chromaHighlighter) Highlight(code, lang string, opts interface{}) (string, error) {
|
||||
func (h chromaHighlighter) Highlight(code, lang string, opts any) (string, error) {
|
||||
cfg := h.cfg
|
||||
if err := applyOptions(opts, &cfg); err != nil {
|
||||
return "", err
|
||||
@@ -82,7 +82,7 @@ func (h chromaHighlighter) Highlight(code, lang string, opts interface{}) (strin
|
||||
return b.String(), nil
|
||||
}
|
||||
|
||||
func (h chromaHighlighter) HighlightCodeBlock(ctx hooks.CodeblockContext, opts interface{}) (HightlightResult, error) {
|
||||
func (h chromaHighlighter) HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HightlightResult, error) {
|
||||
cfg := h.cfg
|
||||
|
||||
var b strings.Builder
|
||||
|
Reference in New Issue
Block a user