Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions helpers/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,15 @@ func ExtractTOC(content []byte) (newcontent []byte, toc []byte) {
// for a given content rendering.
// By creating you must set the Config, otherwise it will panic.
type RenderingContext struct {
Content []byte
PageFmt string
DocumentID string
DocumentName string
Config *BlackFriday
RenderTOC bool
Cfg config.Provider
Frontmatter map[string]interface{}
FrontmatterRaw []byte
Content []byte
PageFmt string
DocumentID string
DocumentName string
Config *BlackFriday
RenderTOC bool
Cfg config.Provider
}

// RenderBytes renders a []byte.
Expand Down Expand Up @@ -715,7 +717,18 @@ func getPandocContent(ctx *RenderingContext) []byte {
" Leaving pandoc content unrendered.")
return ctx.Content
}

jww.INFO.Println("Rendering", ctx.DocumentName, "with", path, "...")
args := []string{"--mathjax"}

pathCiteproc, errCiteproc := exec.LookPath("pandoc-citeproc")
if errCiteproc == nil {
if bib, ok := ctx.Frontmatter["bibliography"].(string); ok {
args = append(args, "--filter", "pandoc-citeproc")
jww.INFO.Println("Rendering bibliography", bib, "with", pathCiteproc, "...")
}
}

return externallyRenderContent(ctx, path, args)
}

Expand All @@ -727,7 +740,8 @@ func orgRender(ctx *RenderingContext, c ContentSpec) []byte {
}

func externallyRenderContent(ctx *RenderingContext, path string, args []string) []byte {
content := ctx.Content
content := ctx.FrontmatterRaw
content = append(content, ctx.Content...)
cleanContent := bytes.Replace(content, SummaryDivider, []byte(""), 1)

cmd := exec.Command(path, args...)
Expand Down
4 changes: 3 additions & 1 deletion hugolib/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,9 @@ func (p *Page) setAutoSummary() error {

func (p *Page) renderContent(content []byte) []byte {
return p.s.ContentSpec.RenderBytes(&helpers.RenderingContext{
Content: content, RenderTOC: true, PageFmt: p.Markup,
Frontmatter: p.params,
FrontmatterRaw: p.frontmatter,
Content: content, RenderTOC: true, PageFmt: p.Markup,
Cfg: p.Language(),
DocumentID: p.UniqueID(), DocumentName: p.Path(),
Config: p.getRenderingConfig()})
Expand Down