From 613139e7bef81d3573e7988a47eb6765f3de347a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 23 Oct 2019 23:03:17 -0700 Subject: 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 --- pkg/markup/markdown.go | 4 ++-- pkg/markup/markdown_test.go | 4 ++-- pkg/markup/markup.go | 6 +++--- pkg/markup/markup_test.go | 4 ++-- pkg/markup/orgmode.go | 18 +++++++----------- pkg/markup/sanitizer.go | 2 +- pkg/markup/sanitizer_test.go | 2 +- 7 files changed, 18 insertions(+), 22 deletions(-) (limited to 'pkg/markup') diff --git a/pkg/markup/markdown.go b/pkg/markup/markdown.go index 77fb6dbe..236c7337 100644 --- a/pkg/markup/markdown.go +++ b/pkg/markup/markdown.go @@ -14,8 +14,8 @@ import ( "github.com/russross/blackfriday" - "github.com/gogs/gogs/pkg/setting" - "github.com/gogs/gogs/pkg/tool" + "gogs.io/gogs/pkg/setting" + "gogs.io/gogs/pkg/tool" ) // IsMarkdownFile reports whether name looks like a Markdown file based on its extension. diff --git a/pkg/markup/markdown_test.go b/pkg/markup/markdown_test.go index ee743452..5acdddc8 100644 --- a/pkg/markup/markdown_test.go +++ b/pkg/markup/markdown_test.go @@ -12,8 +12,8 @@ import ( "github.com/russross/blackfriday" . "github.com/smartystreets/goconvey/convey" - . "github.com/gogs/gogs/pkg/markup" - "github.com/gogs/gogs/pkg/setting" + . "gogs.io/gogs/pkg/markup" + "gogs.io/gogs/pkg/setting" ) func Test_IsMarkdownFile(t *testing.T) { diff --git a/pkg/markup/markup.go b/pkg/markup/markup.go index ee91b7b1..a70d4b2a 100644 --- a/pkg/markup/markup.go +++ b/pkg/markup/markup.go @@ -11,11 +11,11 @@ import ( "regexp" "strings" - "github.com/Unknwon/com" + "github.com/unknwon/com" "golang.org/x/net/html" - "github.com/gogs/gogs/pkg/setting" - "github.com/gogs/gogs/pkg/tool" + "gogs.io/gogs/pkg/setting" + "gogs.io/gogs/pkg/tool" ) // IsReadmeFile reports whether name looks like a README file based on its extension. diff --git a/pkg/markup/markup_test.go b/pkg/markup/markup_test.go index 97250d6c..fbf28bf0 100644 --- a/pkg/markup/markup_test.go +++ b/pkg/markup/markup_test.go @@ -10,8 +10,8 @@ import ( . "github.com/smartystreets/goconvey/convey" - . "github.com/gogs/gogs/pkg/markup" - "github.com/gogs/gogs/pkg/setting" + . "gogs.io/gogs/pkg/markup" + "gogs.io/gogs/pkg/setting" ) func Test_IsReadmeFile(t *testing.T) { 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. diff --git a/pkg/markup/sanitizer.go b/pkg/markup/sanitizer.go index 3f1e41b7..bc6c0a77 100644 --- a/pkg/markup/sanitizer.go +++ b/pkg/markup/sanitizer.go @@ -10,7 +10,7 @@ import ( "github.com/microcosm-cc/bluemonday" - "github.com/gogs/gogs/pkg/setting" + "gogs.io/gogs/pkg/setting" ) // Sanitizer is a protection wrapper of *bluemonday.Policy which does not allow diff --git a/pkg/markup/sanitizer_test.go b/pkg/markup/sanitizer_test.go index 194c27af..1e394512 100644 --- a/pkg/markup/sanitizer_test.go +++ b/pkg/markup/sanitizer_test.go @@ -9,7 +9,7 @@ import ( . "github.com/smartystreets/goconvey/convey" - . "github.com/gogs/gogs/pkg/markup" + . "gogs.io/gogs/pkg/markup" ) func Test_Sanitizer(t *testing.T) { -- cgit v1.2.3