Handle ToC before handling shortcodes

Fixes #2433
This commit is contained in:
Luca Corbatto
2016-10-24 14:40:57 +02:00
committed by Bjørn Erik Pedersen
parent 165edc7f0a
commit d9f54a13c1
2 changed files with 114 additions and 4 deletions

View File

@@ -466,16 +466,16 @@ func (s *Site) preparePagesForRender(cfg BuildCfg, changed whatChanged) {
p.rawContentCopy = p.rawContent
}
if err := handleShortcodes(p, s.owner.tmpl); err != nil {
jww.ERROR.Printf("Failed to handle shortcodes for page %s: %s", p.BaseFileName(), err)
}
if p.Markup == "markdown" {
tmpContent, tmpTableOfContents := helpers.ExtractTOC(p.rawContentCopy)
p.TableOfContents = helpers.BytesToHTML(tmpTableOfContents)
p.rawContentCopy = tmpContent
}
if err := handleShortcodes(p, s.owner.tmpl); err != nil {
jww.ERROR.Printf("Failed to handle shortcodes for page %s: %s", p.BaseFileName(), err)
}
if p.Markup != "html" {
// Now we know enough to create a summary of the page and count some words