diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/content.go | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/helpers/content.go b/helpers/content.go index 3892647bb..6d9f1ca08 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -27,8 +27,8 @@ import ( "unicode/utf8" "github.com/gohugoio/hugo/common/maps" + "github.com/niklasfasching/go-org/org" - "github.com/chaseadamsio/goorgeous" bp "github.com/gohugoio/hugo/bufferpool" "github.com/gohugoio/hugo/config" "github.com/miekg/mmark" @@ -756,10 +756,24 @@ func getPandocContent(ctx *RenderingContext) []byte { } func orgRender(ctx *RenderingContext, c ContentSpec) []byte { - content := ctx.Content - cleanContent := bytes.Replace(content, []byte("# more"), []byte(""), 1) - return goorgeous.Org(cleanContent, - c.getHTMLRenderer(blackfriday.HTML_TOC, ctx)) + config := org.New() + config.Log = jww.WARN + writer := org.NewHTMLWriter() + writer.HighlightCodeBlock = func(source, lang string) string { + highlightedSource, err := c.Highlight(source, lang, "") + if err != nil { + jww.ERROR.Printf("Could not highlight source as lang %s. Using raw source.", lang) + return source + } + return highlightedSource + } + + html, err := config.Parse(bytes.NewReader(ctx.Content), ctx.DocumentName).Write(writer) + if err != nil { + jww.ERROR.Printf("Could not render org: %s. Using unrendered content.", err) + return ctx.Content + } + return []byte(html) } func externallyRenderContent(ctx *RenderingContext, path string, args []string) []byte { |