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/site.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/site.go')
-rw-r--r-- | hugolib/site.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/hugolib/site.go b/hugolib/site.go index b9ec64224..db0cd2ea5 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -28,6 +28,8 @@ import ( "strings" "time" + "github.com/gohugoio/hugo/markup/converter" + "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/common/maps" @@ -758,17 +760,23 @@ func (s *siteRefLinker) refLink(ref string, source interface{}, relative bool, o } if refURL.Fragment != "" { + _ = target link = link + "#" + refURL.Fragment - if pctx, ok := target.(pageContext); ok && !target.File().IsZero() && !pctx.getRenderingConfig().PlainIDAnchors { + if pctx, ok := target.(pageContext); ok { if refURL.Path != "" { - link = link + ":" + target.File().UniqueID() + if di, ok := pctx.getContentConverter().(converter.DocumentInfo); ok { + link = link + di.AnchorSuffix() + } + } + } else if pctx, ok := p.(pageContext); ok { + if di, ok := pctx.getContentConverter().(converter.DocumentInfo); ok { + link = link + di.AnchorSuffix() } - } else if pctx, ok := p.(pageContext); ok && !p.File().IsZero() && !pctx.getRenderingConfig().PlainIDAnchors { - link = link + ":" + p.File().UniqueID() } } + return link, nil } |