diff options
author | Lunny Xiao | 2019-05-30 00:05:36 +0800 |
---|---|---|
committer | techknowlogick | 2019-05-29 12:05:36 -0400 |
commit | 31ad8b702630116104d99eacad61f79e46176562 (patch) | |
tree | d266cf6b093c5944576f40479558967b8b689950 | |
parent | d07edc5336342b8cce2eb44a61806f15782d5728 (diff) |
Fix wrong init dependency on markup extensions (#7038) (#7074)
* fix wrong init dependency on markup extensions
-rw-r--r-- | cmd/web.go | 3 | ||||
-rw-r--r-- | contrib/pr/checkout.go | 2 | ||||
-rw-r--r-- | modules/markup/markup.go | 8 | ||||
-rw-r--r-- | routers/init.go | 2 |
4 files changed, 12 insertions, 3 deletions
diff --git a/cmd/web.go b/cmd/web.go index 8fed559ff..5f932032b 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -15,7 +15,6 @@ import ( "strings" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/markup/external" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers" "code.gitea.io/gitea/routers/routes" @@ -120,8 +119,6 @@ func runWeb(ctx *cli.Context) error { routers.GlobalInit() - external.RegisterParsers() - m := routes.NewMacaron() routes.RegisterRoutes(m) diff --git a/contrib/pr/checkout.go b/contrib/pr/checkout.go index 9fe1eb573..fffa8bd12 100644 --- a/contrib/pr/checkout.go +++ b/contrib/pr/checkout.go @@ -20,6 +20,7 @@ import ( "strconv" "time" + "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/external" "code.gitea.io/gitea/routers" "code.gitea.io/gitea/routers/routes" @@ -113,6 +114,7 @@ func runPR() { log.Printf("[PR] Setting up router\n") //routers.GlobalInit() external.RegisterParsers() + markup.Init() m := routes.NewMacaron() routes.RegisterRoutes(m) diff --git a/modules/markup/markup.go b/modules/markup/markup.go index c50600772..1269714f0 100644 --- a/modules/markup/markup.go +++ b/modules/markup/markup.go @@ -15,6 +15,14 @@ import ( func Init() { getIssueFullPattern() NewSanitizer() + + // since setting maybe changed extensions, this will reload all parser extensions mapping + extParsers = make(map[string]Parser) + for _, parser := range parsers { + for _, ext := range parser.Extensions() { + extParsers[strings.ToLower(ext)] = parser + } + } } // Parser defines an interface for parsering markup file to HTML diff --git a/routers/init.go b/routers/init.go index 2fc3bb966..44e763fc1 100644 --- a/routers/init.go +++ b/routers/init.go @@ -19,6 +19,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/mailer" "code.gitea.io/gitea/modules/markup" + "code.gitea.io/gitea/modules/markup/external" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/ssh" @@ -75,6 +76,7 @@ func GlobalInit() { if setting.InstallLock { highlight.NewContext() + external.RegisterParsers() markup.Init() if err := initDBEngine(); err == nil { log.Info("ORM engine initialization successful!") |