mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Add render template hooks for links and images
This commit also * revises the change detection for templates used by content files in server mode. * Adds a Page.RenderString method Fixes #6545 Fixes #4663 Closes #6043
This commit is contained in:
@@ -38,6 +38,9 @@ func TestConvert(t *testing.T) {
|
||||
https://github.com/gohugoio/hugo/issues/6528
|
||||
[Live Demo here!](https://docuapi.netlify.com/)
|
||||
|
||||
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
||||
|
||||
|
||||
## Code Fences
|
||||
|
||||
§§§bash
|
||||
@@ -98,6 +101,7 @@ description
|
||||
|
||||
mconf := markup_config.Default
|
||||
mconf.Highlight.NoClasses = false
|
||||
mconf.Goldmark.Renderer.Unsafe = true
|
||||
|
||||
p, err := Provider.New(
|
||||
converter.ProviderConfig{
|
||||
@@ -106,15 +110,15 @@ description
|
||||
},
|
||||
)
|
||||
c.Assert(err, qt.IsNil)
|
||||
conv, err := p.New(converter.DocumentContext{})
|
||||
conv, err := p.New(converter.DocumentContext{DocumentID: "thedoc"})
|
||||
c.Assert(err, qt.IsNil)
|
||||
b, err := conv.Convert(converter.RenderContext{Src: []byte(content)})
|
||||
b, err := conv.Convert(converter.RenderContext{RenderTOC: true, Src: []byte(content)})
|
||||
c.Assert(err, qt.IsNil)
|
||||
|
||||
got := string(b.Bytes())
|
||||
|
||||
// Links
|
||||
c.Assert(got, qt.Contains, `<a href="https://docuapi.netlify.com/">Live Demo here!</a>`)
|
||||
// c.Assert(got, qt.Contains, `<a href="https://docuapi.netlify.com/">Live Demo here!</a>`)
|
||||
|
||||
// Header IDs
|
||||
c.Assert(got, qt.Contains, `<h2 id="custom">Custom ID</h2>`, qt.Commentf(got))
|
||||
@@ -137,6 +141,11 @@ description
|
||||
c.Assert(got, qt.Contains, `<section class="footnotes" role="doc-endnotes">`)
|
||||
c.Assert(got, qt.Contains, `<dt>date</dt>`)
|
||||
|
||||
toc, ok := b.(converter.TableOfContentsProvider)
|
||||
c.Assert(ok, qt.Equals, true)
|
||||
tocHTML := toc.TableOfContents().ToHTML(1, 2, false)
|
||||
c.Assert(tocHTML, qt.Contains, "TableOfContents")
|
||||
|
||||
}
|
||||
|
||||
func TestCodeFence(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user