mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Prepare for Goldmark
This commmit prepares for the addition of Goldmark as the new Markdown renderer in Hugo. This introduces a new `markup` package with some common interfaces and each implementation in its own package. See #5963
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/spf13/afero"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
@@ -894,7 +895,7 @@ func ToTstXIs(slice interface{}) []TstXI {
|
||||
func newDeps(cfg config.Provider) *deps.Deps {
|
||||
l := langs.NewLanguage("en", cfg)
|
||||
l.Set("i18nDir", "i18n")
|
||||
cs, err := helpers.NewContentSpec(l)
|
||||
cs, err := helpers.NewContentSpec(l, loggers.NewErrorLogger(), afero.NewMemMapFs())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -195,7 +195,7 @@ func newDeps(cfg config.Provider) *deps.Deps {
|
||||
}
|
||||
cfg.Set("allModules", modules.Modules{mod})
|
||||
|
||||
cs, err := helpers.NewContentSpec(cfg)
|
||||
cs, err := helpers.NewContentSpec(cfg, loggers.NewErrorLogger(), afero.NewMemMapFs())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -97,19 +97,16 @@ func (ns *Namespace) Markdownify(s interface{}) (template.HTML, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
m := ns.deps.ContentSpec.RenderBytes(
|
||||
&helpers.RenderingContext{
|
||||
Cfg: ns.deps.Cfg,
|
||||
Content: []byte(ss),
|
||||
PageFmt: "markdown",
|
||||
Config: ns.deps.ContentSpec.BlackFriday,
|
||||
},
|
||||
)
|
||||
b, err := ns.deps.ContentSpec.RenderMarkdown([]byte(ss))
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Strip if this is a short inline type of text.
|
||||
m = ns.deps.ContentSpec.TrimShortHTML(m)
|
||||
b = ns.deps.ContentSpec.TrimShortHTML(b)
|
||||
|
||||
return helpers.BytesToHTML(m), nil
|
||||
return helpers.BytesToHTML(b), nil
|
||||
}
|
||||
|
||||
// Plainify returns a copy of s with all HTML tags removed.
|
||||
|
@@ -17,6 +17,9 @@ import (
|
||||
"html/template"
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
"github.com/spf13/afero"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/config"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
@@ -239,7 +242,7 @@ func newDeps(cfg config.Provider) *deps.Deps {
|
||||
|
||||
l := langs.NewLanguage("en", cfg)
|
||||
|
||||
cs, err := helpers.NewContentSpec(l)
|
||||
cs, err := helpers.NewContentSpec(l, loggers.NewErrorLogger(), afero.NewMemMapFs())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user