diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-16 15:55:03 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-11-06 19:09:08 +0100 |
commit | 5f6b6ec68936ebbbf590894c02a1a3ecad30735f (patch) | |
tree | f6c91e225a3f24f51af1bde5cfb5b88515d0665d /hugolib/shortcode.go | |
parent | 366ee4d8da1c2b0c1751e9bf6d54638439735296 (diff) |
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
Diffstat (limited to 'hugolib/shortcode.go')
-rw-r--r-- | hugolib/shortcode.go | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index d0cdf3950..700ac5bd8 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -21,6 +21,8 @@ import ( "html/template" "path" + "github.com/gohugoio/hugo/markup/converter" + "github.com/gohugoio/hugo/common/herrors" "github.com/pkg/errors" @@ -43,7 +45,6 @@ import ( "github.com/gohugoio/hugo/output" bp "github.com/gohugoio/hugo/bufferpool" - "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/tpl" ) @@ -347,13 +348,19 @@ func renderShortcode( // Pre Hugo 0.55 this was the behaviour even for the outer-most // shortcode. if sc.doMarkup && (level > 0 || sc.info.Config.Version == 1) { - newInner := s.ContentSpec.RenderBytes(&helpers.RenderingContext{ - Content: []byte(inner), - PageFmt: p.m.markup, - Cfg: p.Language(), - DocumentID: p.File().UniqueID(), - DocumentName: p.File().Path(), - Config: p.getRenderingConfig()}) + var err error + + b, err := p.getContentConverter().Convert( + converter.RenderContext{ + Src: []byte(inner), + }, + ) + + if err != nil { + return "", false, err + } + + newInner := b.Bytes() // If the type is “” (unknown) or “markdown”, we assume the markdown // generation has been performed. Given the input: `a line`, markdown |