mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02:00
Improve Org mode support: Replace goorgeous with go-org
Sadly, goorgeous has not been updated in over a year and still has a lot of open issues (e.g. no support for nested lists). go-org fixes most of those issues and supports a larger subset of Org mode syntax.
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
9df57154ee
commit
b6867bf806
@@ -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 {
|
||||
|
Reference in New Issue
Block a user