mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Restructure markup & markdown to prepare for multiple markup language… (#2411)
* restructure markup & markdown to prepare for multiple markup languages support * adjust some functions between markdown and markup * fix tests * improve the comments
This commit is contained in:
		@@ -9,6 +9,7 @@ import (
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/context"
 | 
			
		||||
	"code.gitea.io/gitea/modules/markdown"
 | 
			
		||||
	"code.gitea.io/gitea/modules/markup"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +40,7 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
 | 
			
		||||
	switch form.Mode {
 | 
			
		||||
	case "gfm":
 | 
			
		||||
		md := []byte(form.Text)
 | 
			
		||||
		context := markdown.URLJoin(setting.AppURL, form.Context)
 | 
			
		||||
		context := markup.URLJoin(setting.AppURL, form.Context)
 | 
			
		||||
		if form.Wiki {
 | 
			
		||||
			ctx.Write([]byte(markdown.RenderWiki(md, context, nil)))
 | 
			
		||||
		} else {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,23 +1,21 @@
 | 
			
		||||
package misc
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/http/httptest"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	macaron "gopkg.in/macaron.v1"
 | 
			
		||||
 | 
			
		||||
	"net/url"
 | 
			
		||||
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/context"
 | 
			
		||||
	"code.gitea.io/gitea/modules/markdown"
 | 
			
		||||
	"code.gitea.io/gitea/modules/markup"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
	api "code.gitea.io/sdk/gitea"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-macaron/inject"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	macaron "gopkg.in/macaron.v1"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const AppURL = "http://localhost:3000/"
 | 
			
		||||
@@ -55,7 +53,7 @@ func TestAPI_RenderGFM(t *testing.T) {
 | 
			
		||||
		Context: Repo,
 | 
			
		||||
		Wiki:    true,
 | 
			
		||||
	}
 | 
			
		||||
	requrl, _ := url.Parse(markdown.URLJoin(AppURL, "api", "v1", "markdown"))
 | 
			
		||||
	requrl, _ := url.Parse(markup.URLJoin(AppURL, "api", "v1", "markdown"))
 | 
			
		||||
	req := &http.Request{
 | 
			
		||||
		Method: "POST",
 | 
			
		||||
		URL:    requrl,
 | 
			
		||||
@@ -149,7 +147,7 @@ func TestAPI_RenderSimple(t *testing.T) {
 | 
			
		||||
		Text:    "",
 | 
			
		||||
		Context: Repo,
 | 
			
		||||
	}
 | 
			
		||||
	requrl, _ := url.Parse(markdown.URLJoin(AppURL, "api", "v1", "markdown"))
 | 
			
		||||
	requrl, _ := url.Parse(markup.URLJoin(AppURL, "api", "v1", "markdown"))
 | 
			
		||||
	req := &http.Request{
 | 
			
		||||
		Method: "POST",
 | 
			
		||||
		URL:    requrl,
 | 
			
		||||
@@ -168,7 +166,7 @@ func TestAPI_RenderSimple(t *testing.T) {
 | 
			
		||||
func TestAPI_RenderRaw(t *testing.T) {
 | 
			
		||||
	setting.AppURL = AppURL
 | 
			
		||||
 | 
			
		||||
	requrl, _ := url.Parse(markdown.URLJoin(AppURL, "api", "v1", "markdown"))
 | 
			
		||||
	requrl, _ := url.Parse(markup.URLJoin(AppURL, "api", "v1", "markdown"))
 | 
			
		||||
	req := &http.Request{
 | 
			
		||||
		Method: "POST",
 | 
			
		||||
		URL:    requrl,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user