summaryrefslogtreecommitdiffstats
path: root/markup
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-17 22:03:27 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-17 22:03:27 +0100
commitb80853de90b10171155b8f3fde47d64ec7bfa0dd (patch)
tree435d3dbf7a495a0c6ce64c9769e037179aa0d27b /markup
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'markup')
-rw-r--r--markup/blackfriday/blackfriday_config/config.go2
-rw-r--r--markup/blackfriday/convert_test.go2
-rw-r--r--markup/converter/converter.go4
-rw-r--r--markup/converter/hooks/hooks.go14
-rw-r--r--markup/goldmark/codeblocks/render.go4
-rw-r--r--markup/goldmark/convert_test.go6
-rw-r--r--markup/goldmark/render_hooks.go10
-rw-r--r--markup/goldmark/toc_test.go2
-rw-r--r--markup/highlight/config.go12
-rw-r--r--markup/highlight/highlight.go8
-rw-r--r--markup/internal/attributes/attributes.go20
-rw-r--r--markup/markup_config/config.go4
-rw-r--r--markup/markup_config/config_test.go16
13 files changed, 52 insertions, 52 deletions
diff --git a/markup/blackfriday/blackfriday_config/config.go b/markup/blackfriday/blackfriday_config/config.go
index f26f7c570..668478ece 100644
--- a/markup/blackfriday/blackfriday_config/config.go
+++ b/markup/blackfriday/blackfriday_config/config.go
@@ -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")
}
diff --git a/markup/blackfriday/convert_test.go b/markup/blackfriday/convert_test.go
index 5b1c1a71f..0d691f646 100644
--- a/markup/blackfriday/convert_test.go
+++ b/markup/blackfriday/convert_test.go
@@ -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,
},
diff --git a/markup/converter/converter.go b/markup/converter/converter.go
index dac0a6b73..1ea301aa6 100644
--- a/markup/converter/converter.go
+++ b/markup/converter/converter.go
@@ -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.
diff --git a/markup/converter/hooks/hooks.go b/markup/converter/hooks/hooks.go
index 2f2d5e6cb..dc5da5a30 100644
--- a/markup/converter/hooks/hooks.go
+++ b/markup/converter/hooks/hooks.go
@@ -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
diff --git a/markup/goldmark/codeblocks/render.go b/markup/goldmark/codeblocks/render.go
index 97604eb55..fa6d236a1 100644
--- a/markup/goldmark/codeblocks/render.go
+++ b/markup/goldmark/codeblocks/render.go
@@ -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
}
diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go
index 83d97f222..e37e81c97 100644
--- a/markup/goldmark/convert_test.go
+++ b/markup/goldmark/convert_test.go
@@ -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
}
diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go
index 6aafc70e1..e28f816d6 100644
--- a/markup/goldmark/render_hooks.go
+++ b/markup/goldmark/render_hooks.go
@@ -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)
}
diff --git a/markup/goldmark/toc_test.go b/markup/goldmark/toc_test.go
index 6e080bf46..947f58a36 100644
--- a/markup/goldmark/toc_test.go
+++ b/markup/goldmark/toc_test.go
@@ -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)
diff --git a/markup/highlight/config.go b/markup/highlight/config.go
index 1142c5e11..08c1bca1a 100644
--- a/markup/highlight/config.go
+++ b/markup/highlight/config.go
@@ -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
}
diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go
index 892cb72ee..8e7f6ee30 100644
--- a/markup/highlight/highlight.go
+++ b/markup/highlight/highlight.go
@@ -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
diff --git a/markup/internal/attributes/attributes.go b/markup/internal/attributes/attributes.go
index a20690c4c..edf857822 100644
--- a/markup/internal/attributes/attributes.go
+++ b/markup/internal/attributes/attributes.go
@@ -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
}
diff --git a/markup/markup_config/config.go b/markup/markup_config/config.go
index d4a101709..ddcba8c3a 100644
--- a/markup/markup_config/config.go
+++ b/markup/markup_config/config.go
@@ -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)
}
diff --git a/markup/markup_config/config_test.go b/markup/markup_config/config_test.go
index 08d7b5995..06bd0b11c 100644
--- a/markup/markup_config/config_test.go
+++ b/markup/markup_config/config_test.go
@@ -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
},
},