Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/markup
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-02-09 11:23:18 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-02-09 11:23:18 +0300
commite6dd312812c7c711986af2d60f2999d116b82ea0 (patch)
treee3f4ec30253042a4dc36e9b0c427d06b72fd78fa /markup
parent2681633db8d340d2dc59cf801419874d572fc704 (diff)
markup/goldmark: Fix handling of legacy attribute config
See #7548
Diffstat (limited to 'markup')
-rw-r--r--markup/markup_config/config.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/markup/markup_config/config.go b/markup/markup_config/config.go
index 725e04b84..a3562cd24 100644
--- a/markup/markup_config/config.go
+++ b/markup/markup_config/config.go
@@ -14,6 +14,7 @@
package markup_config
import (
+ "github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/docshelper"
"github.com/gohugoio/hugo/markup/asciidocext/asciidocext_config"
@@ -23,6 +24,7 @@ import (
"github.com/gohugoio/hugo/markup/tableofcontents"
"github.com/gohugoio/hugo/parser"
"github.com/mitchellh/mapstructure"
+ "github.com/spf13/cast"
)
type Config struct {
@@ -44,12 +46,11 @@ type Config struct {
func Decode(cfg config.Provider) (conf Config, err error) {
conf = Default
- normalizeConfig(cfg)
-
m := cfg.GetStringMap("markup")
if m == nil {
return
}
+ normalizeConfig(m)
err = mapstructure.WeakDecode(m, &conf)
if err != nil {
@@ -67,14 +68,19 @@ func Decode(cfg config.Provider) (conf Config, err error) {
return
}
-func normalizeConfig(cfg config.Provider) {
+func normalizeConfig(m map[string]interface{}) {
+ v, err := maps.GetNestedParam("goldmark.parser", ".", m)
+ if err != nil {
+ return
+ }
+ vm := cast.ToStringMap(v)
// Changed from a bool in 0.81.0
- const attrKey = "markup.goldmark.parser.attribute"
- av := cfg.Get(attrKey)
- if avb, ok := av.(bool); ok {
- cfg.Set(attrKey, goldmark_config.ParserAttribute{
- Title: avb,
- })
+ if vv, found := vm["attribute"]; found {
+ if vvb, ok := vv.(bool); ok {
+ vm["attribute"] = goldmark_config.ParserAttribute{
+ Title: vvb,
+ }
+ }
}
}