diff options
author | Unknwon <u@gogs.io> | 2019-10-23 23:03:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-23 23:03:17 -0700 |
commit | 613139e7bef81d3573e7988a47eb6765f3de347a (patch) | |
tree | 49de7277898d3ff47a122c072568edb8ed4c9ac9 /pkg/markup/orgmode.go | |
parent | fb100dbf98f02e4c631d142ff0f52ec29ee2f00c (diff) |
Enable Go modules (#5835)
* Remove vendor
* Enable Go modules
* ci: add command to fetch dependencies
* ci: update setting
* ci: update settings
* Require Go 1.11
* Rename module name to gogs.io/gogs
Diffstat (limited to 'pkg/markup/orgmode.go')
-rw-r--r-- | pkg/markup/orgmode.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/markup/orgmode.go b/pkg/markup/orgmode.go index f62cced2..6fe1240a 100644 --- a/pkg/markup/orgmode.go +++ b/pkg/markup/orgmode.go @@ -5,12 +5,11 @@ package markup import ( + "bytes" "path/filepath" "strings" - log "gopkg.in/clog.v1" - - "github.com/chaseadamsio/goorgeous" + "github.com/niklasfasching/go-org/org" ) var orgModeExtensions = []string{".org"} @@ -28,14 +27,11 @@ func IsOrgModeFile(name string) bool { // RawOrgMode renders content in Org-mode syntax to HTML without handling special links. func RawOrgMode(body []byte, urlPrefix string) (result []byte) { - // TODO: remove recover code once the third-party package is stable - defer func() { - if err := recover(); err != nil { - result = body - log.Warn("PANIC (RawOrgMode): %v", err) - } - }() - return goorgeous.OrgCommon(body) + html, err := org.New().Silent().Parse(bytes.NewReader(body), urlPrefix).Write(org.NewHTMLWriter()) + if err != nil { + return []byte(err.Error()) + } + return []byte(html) } // OrgMode takes a string or []byte and renders to HTML in Org-mode syntax with special links. |