mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
Remove Blackfriday markdown engine
It has been deprecated for a long time, its v1 version is not maintained anymore, and there are many known issues. Goldmark should be a mature replacement by now. Closes #9934
This commit is contained in:
parent
3b478f50b7
commit
0f8dc47037
22 changed files with 71 additions and 1675 deletions
|
@ -18,7 +18,6 @@ import (
|
|||
"github.com/gohugoio/hugo/config"
|
||||
"github.com/gohugoio/hugo/docshelper"
|
||||
"github.com/gohugoio/hugo/markup/asciidocext/asciidocext_config"
|
||||
"github.com/gohugoio/hugo/markup/blackfriday/blackfriday_config"
|
||||
"github.com/gohugoio/hugo/markup/goldmark/goldmark_config"
|
||||
"github.com/gohugoio/hugo/markup/highlight"
|
||||
"github.com/gohugoio/hugo/markup/tableofcontents"
|
||||
|
@ -37,8 +36,6 @@ type Config struct {
|
|||
|
||||
// Content renderers
|
||||
Goldmark goldmark_config.Config
|
||||
BlackFriday blackfriday_config.Config
|
||||
|
||||
AsciidocExt asciidocext_config.Config
|
||||
}
|
||||
|
||||
|
@ -56,10 +53,6 @@ func Decode(cfg config.Provider) (conf Config, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = applyLegacyConfig(cfg, &conf); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = highlight.ApplyLegacyConfig(cfg, &conf.Highlight); err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -83,26 +76,6 @@ func normalizeConfig(m map[string]any) {
|
|||
}
|
||||
}
|
||||
|
||||
func applyLegacyConfig(cfg config.Provider, conf *Config) error {
|
||||
if bm := cfg.GetStringMap("blackfriday"); bm != nil {
|
||||
// Legacy top level blackfriday config.
|
||||
err := mapstructure.WeakDecode(bm, &conf.BlackFriday)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if conf.BlackFriday.FootnoteAnchorPrefix == "" {
|
||||
conf.BlackFriday.FootnoteAnchorPrefix = cfg.GetString("footnoteAnchorPrefix")
|
||||
}
|
||||
|
||||
if conf.BlackFriday.FootnoteReturnLinkContents == "" {
|
||||
conf.BlackFriday.FootnoteReturnLinkContents = cfg.GetString("footnoteReturnLinkContents")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var Default = Config{
|
||||
DefaultMarkdownHandler: "goldmark",
|
||||
|
||||
|
@ -110,8 +83,6 @@ var Default = Config{
|
|||
Highlight: highlight.DefaultConfig,
|
||||
|
||||
Goldmark: goldmark_config.Default,
|
||||
BlackFriday: blackfriday_config.Default,
|
||||
|
||||
AsciidocExt: asciidocext_config.Default,
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ func TestConfig(t *testing.T) {
|
|||
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(conf.Goldmark.Renderer.Unsafe, qt.Equals, true)
|
||||
c.Assert(conf.BlackFriday.Fractions, qt.Equals, true)
|
||||
c.Assert(conf.Goldmark.Parser.Attribute.Title, qt.Equals, true)
|
||||
c.Assert(conf.Goldmark.Parser.Attribute.Block, qt.Equals, false)
|
||||
|
||||
|
@ -53,37 +52,4 @@ func TestConfig(t *testing.T) {
|
|||
c.Assert(conf.AsciidocExt.Extensions[0], qt.Equals, "asciidoctor-html5s")
|
||||
})
|
||||
|
||||
c.Run("legacy", func(c *qt.C) {
|
||||
c.Parallel()
|
||||
v := config.New()
|
||||
|
||||
v.Set("blackfriday", map[string]any{
|
||||
"angledQuotes": true,
|
||||
})
|
||||
|
||||
v.Set("footnoteAnchorPrefix", "myprefix")
|
||||
v.Set("footnoteReturnLinkContents", "myreturn")
|
||||
v.Set("pygmentsStyle", "hugo")
|
||||
v.Set("pygmentsCodefencesGuessSyntax", true)
|
||||
|
||||
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
|
||||
},
|
||||
},
|
||||
})
|
||||
conf, err := Decode(v)
|
||||
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(conf.BlackFriday.AngledQuotes, qt.Equals, true)
|
||||
c.Assert(conf.BlackFriday.FootnoteAnchorPrefix, qt.Equals, "myprefix")
|
||||
c.Assert(conf.BlackFriday.FootnoteReturnLinkContents, qt.Equals, "myreturn")
|
||||
c.Assert(conf.Highlight.Style, qt.Equals, "hugo")
|
||||
c.Assert(conf.Highlight.CodeFences, qt.Equals, true)
|
||||
c.Assert(conf.Highlight.GuessSyntax, qt.Equals, true)
|
||||
c.Assert(conf.Goldmark.Parser.Attribute.Title, qt.Equals, false)
|
||||
c.Assert(conf.Goldmark.Parser.Attribute.Block, qt.Equals, false)
|
||||
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue