mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
@@ -62,7 +62,7 @@ type Config struct {
|
||||
FootnoteReturnLinkContents string
|
||||
}
|
||||
|
||||
func UpdateConfig(b Config, m map[string]interface{}) (Config, error) {
|
||||
func UpdateConfig(b Config, m map[string]any) (Config, error) {
|
||||
if err := mapstructure.Decode(m, &b); err != nil {
|
||||
return b, errors.WithMessage(err, "failed to decode rendering config")
|
||||
}
|
||||
|
@@ -158,7 +158,7 @@ func TestGetHTMLRendererAnchors(t *testing.T) {
|
||||
c.Assert(err, qt.IsNil)
|
||||
conv, err := p.New(converter.DocumentContext{
|
||||
DocumentID: "testid",
|
||||
ConfigOverrides: map[string]interface{}{
|
||||
ConfigOverrides: map[string]any{
|
||||
"plainIDAnchors": false,
|
||||
"footnotes": true,
|
||||
},
|
||||
|
@@ -119,11 +119,11 @@ func (b Bytes) Bytes() []byte {
|
||||
|
||||
// DocumentContext holds contextual information about the document to convert.
|
||||
type DocumentContext struct {
|
||||
Document interface{} // May be nil. Usually a page.Page
|
||||
Document any // May be nil. Usually a page.Page
|
||||
DocumentID string
|
||||
DocumentName string
|
||||
Filename string
|
||||
ConfigOverrides map[string]interface{}
|
||||
ConfigOverrides map[string]any
|
||||
}
|
||||
|
||||
// RenderContext holds contextual information about the content to render.
|
||||
|
@@ -26,11 +26,11 @@ import (
|
||||
var _ AttributesOptionsSliceProvider = (*attributes.AttributesHolder)(nil)
|
||||
|
||||
type AttributesProvider interface {
|
||||
Attributes() map[string]interface{}
|
||||
Attributes() map[string]any
|
||||
}
|
||||
|
||||
type LinkContext interface {
|
||||
Page() interface{}
|
||||
Page() any
|
||||
Destination() string
|
||||
Title() string
|
||||
Text() hstring.RenderedString
|
||||
@@ -40,11 +40,11 @@ type LinkContext interface {
|
||||
type CodeblockContext interface {
|
||||
AttributesProvider
|
||||
text.Positioner
|
||||
Options() map[string]interface{}
|
||||
Options() map[string]any
|
||||
Type() string
|
||||
Inner() string
|
||||
Ordinal() int
|
||||
Page() interface{}
|
||||
Page() any
|
||||
}
|
||||
|
||||
type AttributesOptionsSliceProvider interface {
|
||||
@@ -70,7 +70,7 @@ type IsDefaultCodeBlockRendererProvider interface {
|
||||
// can use to render a heading.
|
||||
type HeadingContext interface {
|
||||
// Page is the page containing the heading.
|
||||
Page() interface{}
|
||||
Page() any
|
||||
// Level is the level of the header (i.e. 1 for top-level, 2 for sub-level, etc.).
|
||||
Level() int
|
||||
// Anchor is the HTML id assigned to the heading.
|
||||
@@ -96,7 +96,7 @@ type HeadingRenderer interface {
|
||||
// This may be both slow and aproximate, so should only be
|
||||
// used for error logging.
|
||||
type ElementPositionResolver interface {
|
||||
ResolvePosition(ctx interface{}) text.Position
|
||||
ResolvePosition(ctx any) text.Position
|
||||
}
|
||||
|
||||
type RendererType int
|
||||
@@ -108,4 +108,4 @@ const (
|
||||
CodeBlockRendererType
|
||||
)
|
||||
|
||||
type GetRendererFunc func(t RendererType, id interface{}) interface{}
|
||||
type GetRendererFunc func(t RendererType, id any) any
|
||||
|
@@ -132,7 +132,7 @@ func (r *htmlRenderer) renderCodeBlock(w util.BufWriter, src []byte, node ast.No
|
||||
}
|
||||
|
||||
type codeBlockContext struct {
|
||||
page interface{}
|
||||
page any
|
||||
lang string
|
||||
code string
|
||||
ordinal int
|
||||
@@ -146,7 +146,7 @@ type codeBlockContext struct {
|
||||
*attributes.AttributesHolder
|
||||
}
|
||||
|
||||
func (c *codeBlockContext) Page() interface{} {
|
||||
func (c *codeBlockContext) Page() any {
|
||||
return c.page
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,7 @@ func convert(c *qt.C, mconf markup_config.Config, content string) converter.Resu
|
||||
c.Assert(err, qt.IsNil)
|
||||
h := highlight.New(mconf.Highlight)
|
||||
|
||||
getRenderer := func(t hooks.RendererType, id interface{}) interface{} {
|
||||
getRenderer := func(t hooks.RendererType, id any) any {
|
||||
if t == hooks.CodeBlockRendererType {
|
||||
return h
|
||||
}
|
||||
@@ -233,7 +233,7 @@ func TestConvertAttributes(t *testing.T) {
|
||||
name string
|
||||
withConfig func(conf *markup_config.Config)
|
||||
input string
|
||||
expect interface{}
|
||||
expect any
|
||||
}{
|
||||
{
|
||||
"Title",
|
||||
@@ -408,7 +408,7 @@ LINE5
|
||||
|
||||
h := highlight.New(conf)
|
||||
|
||||
getRenderer := func(t hooks.RendererType, id interface{}) interface{} {
|
||||
getRenderer := func(t hooks.RendererType, id any) any {
|
||||
if t == hooks.CodeBlockRendererType {
|
||||
return h
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ func newLinks(cfg goldmark_config.Config) goldmark.Extender {
|
||||
}
|
||||
|
||||
type linkContext struct {
|
||||
page interface{}
|
||||
page any
|
||||
destination string
|
||||
title string
|
||||
text hstring.RenderedString
|
||||
@@ -62,7 +62,7 @@ func (ctx linkContext) Resolved() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ctx linkContext) Page() interface{} {
|
||||
func (ctx linkContext) Page() any {
|
||||
return ctx.page
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (ctx linkContext) Title() string {
|
||||
}
|
||||
|
||||
type headingContext struct {
|
||||
page interface{}
|
||||
page any
|
||||
level int
|
||||
anchor string
|
||||
text hstring.RenderedString
|
||||
@@ -87,7 +87,7 @@ type headingContext struct {
|
||||
*attributes.AttributesHolder
|
||||
}
|
||||
|
||||
func (ctx headingContext) Page() interface{} {
|
||||
func (ctx headingContext) Page() any {
|
||||
return ctx.page
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ type hookedRenderer struct {
|
||||
html.Config
|
||||
}
|
||||
|
||||
func (r *hookedRenderer) SetOption(name renderer.OptionName, value interface{}) {
|
||||
func (r *hookedRenderer) SetOption(name renderer.OptionName, value any) {
|
||||
r.Config.SetOption(name, value)
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ import (
|
||||
qt "github.com/frankban/quicktest"
|
||||
)
|
||||
|
||||
var nopGetRenderer = func(t hooks.RendererType, id interface{}) interface{} { return nil }
|
||||
var nopGetRenderer = func(t hooks.RendererType, id any) any { return nil }
|
||||
|
||||
func TestToc(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
@@ -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
|
||||
|
@@ -64,11 +64,11 @@ func New(astAttributes []ast.Attribute, ownerType AttributesOwnerType) *Attribut
|
||||
if strings.HasPrefix(string(nameLower), "on") {
|
||||
continue
|
||||
}
|
||||
var vv interface{}
|
||||
var vv any
|
||||
switch vvv := v.Value.(type) {
|
||||
case bool, float64:
|
||||
vv = vvv
|
||||
case []interface{}:
|
||||
case []any:
|
||||
// Highlight line number hlRanges.
|
||||
var hlRanges [][2]int
|
||||
for _, l := range vvv {
|
||||
@@ -118,7 +118,7 @@ func New(astAttributes []ast.Attribute, ownerType AttributesOwnerType) *Attribut
|
||||
|
||||
type Attribute struct {
|
||||
Name string
|
||||
Value interface{}
|
||||
Value any
|
||||
}
|
||||
|
||||
func (a Attribute) ValueString() string {
|
||||
@@ -134,16 +134,16 @@ type AttributesHolder struct {
|
||||
|
||||
// What we send to the the render hooks.
|
||||
attributesMapInit sync.Once
|
||||
attributesMap map[string]interface{}
|
||||
attributesMap map[string]any
|
||||
optionsMapInit sync.Once
|
||||
optionsMap map[string]interface{}
|
||||
optionsMap map[string]any
|
||||
}
|
||||
|
||||
type Attributes map[string]interface{}
|
||||
type Attributes map[string]any
|
||||
|
||||
func (a *AttributesHolder) Attributes() map[string]interface{} {
|
||||
func (a *AttributesHolder) Attributes() map[string]any {
|
||||
a.attributesMapInit.Do(func() {
|
||||
a.attributesMap = make(map[string]interface{})
|
||||
a.attributesMap = make(map[string]any)
|
||||
for _, v := range a.attributes {
|
||||
a.attributesMap[v.Name] = v.Value
|
||||
}
|
||||
@@ -151,9 +151,9 @@ func (a *AttributesHolder) Attributes() map[string]interface{} {
|
||||
return a.attributesMap
|
||||
}
|
||||
|
||||
func (a *AttributesHolder) Options() map[string]interface{} {
|
||||
func (a *AttributesHolder) Options() map[string]any {
|
||||
a.optionsMapInit.Do(func() {
|
||||
a.optionsMap = make(map[string]interface{})
|
||||
a.optionsMap = make(map[string]any)
|
||||
for _, v := range a.options {
|
||||
a.optionsMap[v.Name] = v.Value
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ func Decode(cfg config.Provider) (conf Config, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func normalizeConfig(m map[string]interface{}) {
|
||||
func normalizeConfig(m map[string]any) {
|
||||
v, err := maps.GetNestedParam("goldmark.parser", ".", m)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -117,7 +117,7 @@ var Default = Config{
|
||||
|
||||
func init() {
|
||||
docsProvider := func() docshelper.DocProvider {
|
||||
return docshelper.DocProvider{"config": map[string]interface{}{"markup": parser.LowerCaseCamelJSONMarshaller{Value: Default}}}
|
||||
return docshelper.DocProvider{"config": map[string]any{"markup": parser.LowerCaseCamelJSONMarshaller{Value: Default}}}
|
||||
}
|
||||
docshelper.AddDocProviderFunc(docsProvider)
|
||||
}
|
||||
|
@@ -28,13 +28,13 @@ func TestConfig(t *testing.T) {
|
||||
c.Parallel()
|
||||
v := config.New()
|
||||
|
||||
v.Set("markup", map[string]interface{}{
|
||||
"goldmark": map[string]interface{}{
|
||||
"renderer": map[string]interface{}{
|
||||
v.Set("markup", map[string]any{
|
||||
"goldmark": map[string]any{
|
||||
"renderer": map[string]any{
|
||||
"unsafe": true,
|
||||
},
|
||||
},
|
||||
"asciidocext": map[string]interface{}{
|
||||
"asciidocext": map[string]any{
|
||||
"workingFolderCurrent": true,
|
||||
"safeMode": "save",
|
||||
"extensions": []string{"asciidoctor-html5s"},
|
||||
@@ -57,7 +57,7 @@ func TestConfig(t *testing.T) {
|
||||
c.Parallel()
|
||||
v := config.New()
|
||||
|
||||
v.Set("blackfriday", map[string]interface{}{
|
||||
v.Set("blackfriday", map[string]any{
|
||||
"angledQuotes": true,
|
||||
})
|
||||
|
||||
@@ -66,9 +66,9 @@ func TestConfig(t *testing.T) {
|
||||
v.Set("pygmentsStyle", "hugo")
|
||||
v.Set("pygmentsCodefencesGuessSyntax", true)
|
||||
|
||||
v.Set("markup", map[string]interface{}{
|
||||
"goldmark": map[string]interface{}{
|
||||
"parser": map[string]interface{}{
|
||||
v.Set("markup", map[string]any{
|
||||
"goldmark": map[string]any{
|
||||
"parser": map[string]any{
|
||||
"attribute": false, // Was changed to a struct in 0.81.0
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user