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:
Bjørn Erik Pedersen
2019-08-16 15:55:03 +02:00
parent 366ee4d8da
commit 5f6b6ec689
39 changed files with 1739 additions and 986 deletions

View File

@@ -23,6 +23,8 @@ import (
"sort"
"strings"
"github.com/gohugoio/hugo/markup/converter"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/hugofs/files"
@@ -65,7 +67,7 @@ var (
type pageContext interface {
posOffset(offset int) text.Position
wrapError(err error) error
getRenderingConfig() *helpers.BlackFriday
getContentConverter() converter.Converter
}
// wrapErr adds some context to the given error if possible.
@@ -299,13 +301,6 @@ func (p *pageState) Translations() page.Pages {
return p.translations
}
func (p *pageState) getRenderingConfig() *helpers.BlackFriday {
if p.m.renderingConfig == nil {
return p.s.ContentSpec.BlackFriday
}
return p.m.renderingConfig
}
func (ps *pageState) initCommonProviders(pp pagePaths) error {
if ps.IsPage() {
ps.posNextPrev = &nextPrev{init: ps.s.init.prevNext}
@@ -516,6 +511,10 @@ func (p *pageState) wrapError(err error) error {
return err
}
func (p *pageState) getContentConverter() converter.Converter {
return p.m.contentConverter
}
func (p *pageState) addResources(r ...resource.Resource) {
p.resources = append(p.resources, r...)
}