aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/page__per_output.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-11-06 20:10:47 +0100
committerBjørn Erik Pedersen <[email protected]>2019-11-23 14:12:24 +0100
commitbfb9613a14ab2d93a4474e5486d22e52a9d5e2b3 (patch)
tree81c4dbd10505e952489e1dbcf1d7bafc88b57c28 /hugolib/page__per_output.go
parenta3fe5e5e35f311f22b6b4fc38abfcf64cd2c7d6f (diff)
downloadhugo-bfb9613a14ab2d93a4474e5486d22e52a9d5e2b3.tar.gz
hugo-bfb9613a14ab2d93a4474e5486d22e52a9d5e2b3.zip
Add Goldmark as the new default markdown handler
This commit adds the fast and CommonMark compliant Goldmark as the new default markdown handler in Hugo. If you want to continue using BlackFriday as the default for md/markdown extensions, you can use this configuration: ```toml [markup] defaultMarkdownHandler="blackfriday" ``` Fixes #5963 Fixes #1778 Fixes #6355
Diffstat (limited to 'hugolib/page__per_output.go')
-rw-r--r--hugolib/page__per_output.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/hugolib/page__per_output.go b/hugolib/page__per_output.go
index ef2419eca..59de10be3 100644
--- a/hugolib/page__per_output.go
+++ b/hugolib/page__per_output.go
@@ -77,7 +77,7 @@ func newPageContentOutput(p *pageState) func(f output.Format) (*pageContentOutpu
// See https://github.com/gohugoio/hugo/issues/6210
if r := recover(); r != nil {
err = fmt.Errorf("%s", r)
- p.s.Log.ERROR.Println("[BUG] Got panic:\n", string(debug.Stack()))
+ p.s.Log.ERROR.Printf("[BUG] Got panic:\n%s\n%s", r, string(debug.Stack()))
}
}()
@@ -103,11 +103,14 @@ func newPageContentOutput(p *pageState) func(f output.Format) (*pageContentOutpu
if err != nil {
return err
}
+ cp.convertedResult = r
cp.workContent = r.Bytes()
- tmpContent, tmpTableOfContents := helpers.ExtractTOC(cp.workContent)
- cp.tableOfContents = helpers.BytesToHTML(tmpTableOfContents)
- cp.workContent = tmpContent
+ if _, ok := r.(converter.TableOfContentsProvider); !ok {
+ tmpContent, tmpTableOfContents := helpers.ExtractTOC(cp.workContent)
+ cp.tableOfContents = helpers.BytesToHTML(tmpTableOfContents)
+ cp.workContent = tmpContent
+ }
}
if cp.placeholdersEnabled {
@@ -223,7 +226,8 @@ type pageContentOutput struct {
// Content state
- workContent []byte
+ workContent []byte
+ convertedResult converter.Result
// Temporary storage of placeholders mapped to their content.
// These are shortcodes etc. Some of these will need to be replaced
@@ -284,6 +288,10 @@ func (p *pageContentOutput) Summary() template.HTML {
func (p *pageContentOutput) TableOfContents() template.HTML {
p.p.s.initInit(p.initMain, p.p)
+ if tocProvider, ok := p.convertedResult.(converter.TableOfContentsProvider); ok {
+ cfg := p.p.s.ContentSpec.Converters.GetMarkupConfig()
+ return template.HTML(tocProvider.TableOfContents().ToHTML(cfg.TableOfContents.StartLevel, cfg.TableOfContents.EndLevel))
+ }
return p.tableOfContents
}