summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-09-17 01:17:57 +0800
committerLauris BH <lauris@nix.lv>2017-09-16 20:17:57 +0300
commit52e11b24bf5e395d83ea58c1b0fd6922efe16add (patch)
treef00c9da35c1f2afc3446b8607217e4d4315959ec /models
parent911ca0215377b34559f2304a22dce863e219b255 (diff)
downloadgitea-52e11b24bf5e395d83ea58c1b0fd6922efe16add.tar.gz
gitea-52e11b24bf5e395d83ea58c1b0fd6922efe16add.zip
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
Diffstat (limited to 'models')
-rw-r--r--models/issue_comment.go4
-rw-r--r--models/issue_mail.go4
-rw-r--r--models/mail.go3
-rw-r--r--models/migrations/v16.go4
-rw-r--r--models/repo.go10
-rw-r--r--models/repo_test.go12
6 files changed, 19 insertions, 18 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 6c9c75b1e4..675143437a 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -16,7 +16,7 @@ import (
api "code.gitea.io/sdk/gitea"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/markup"
)
// CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
@@ -272,7 +272,7 @@ func (c *Comment) LoadAssignees() error {
// MailParticipants sends new comment emails to repository watchers
// and mentioned people.
func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
- mentions := markdown.FindAllMentions(c.Content)
+ mentions := markup.FindAllMentions(c.Content)
if err = UpdateIssueMentions(e, c.IssueID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", c.IssueID, err)
}
diff --git a/models/issue_mail.go b/models/issue_mail.go
index 74ef660554..e4a1a40e6d 100644
--- a/models/issue_mail.go
+++ b/models/issue_mail.go
@@ -10,7 +10,7 @@ import (
"github.com/Unknwon/com"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/setting"
)
@@ -104,7 +104,7 @@ func (issue *Issue) MailParticipants() (err error) {
}
func (issue *Issue) mailParticipants(e Engine) (err error) {
- mentions := markdown.FindAllMentions(issue.Content)
+ mentions := markup.FindAllMentions(issue.Content)
if err = UpdateIssueMentions(e, issue.ID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
}
diff --git a/models/mail.go b/models/mail.go
index 41fddad2b4..b7d24a06a1 100644
--- a/models/mail.go
+++ b/models/mail.go
@@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/mailer"
"code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/setting"
"gopkg.in/gomail.v2"
"gopkg.in/macaron.v1"
@@ -150,7 +151,7 @@ func composeTplData(subject, body, link string) map[string]interface{} {
func composeIssueCommentMessage(issue *Issue, doer *User, comment *Comment, tplName base.TplName, tos []string, info string) *mailer.Message {
subject := issue.mailSubject()
- body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas()))
+ body := string(markup.RenderByType(markdown.MarkupName, []byte(issue.Content), issue.Repo.HTMLURL(), issue.Repo.ComposeMetas()))
data := make(map[string]interface{}, 10)
if comment != nil {
diff --git a/models/migrations/v16.go b/models/migrations/v16.go
index 2a6d71de41..ef342a5f88 100644
--- a/models/migrations/v16.go
+++ b/models/migrations/v16.go
@@ -8,7 +8,7 @@ import (
"fmt"
"time"
- "code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/markup"
"github.com/go-xorm/xorm"
)
@@ -101,7 +101,7 @@ func addUnitsToTables(x *xorm.Engine) error {
config["ExternalTrackerURL"] = repo.ExternalTrackerURL
config["ExternalTrackerFormat"] = repo.ExternalTrackerFormat
if len(repo.ExternalTrackerStyle) == 0 {
- repo.ExternalTrackerStyle = markdown.IssueNameStyleNumeric
+ repo.ExternalTrackerStyle = markup.IssueNameStyleNumeric
}
config["ExternalTrackerStyle"] = repo.ExternalTrackerStyle
case V16UnitTypeExternalWiki:
diff --git a/models/repo.go b/models/repo.go
index 8d5b3b87c7..4b3b0322d6 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -22,7 +22,7 @@ import (
"code.gitea.io/git"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
@@ -480,10 +480,10 @@ func (repo *Repository) ComposeMetas() map[string]string {
"repo": repo.Name,
}
switch unit.ExternalTrackerConfig().ExternalTrackerStyle {
- case markdown.IssueNameStyleAlphanumeric:
- repo.ExternalMetas["style"] = markdown.IssueNameStyleAlphanumeric
+ case markup.IssueNameStyleAlphanumeric:
+ repo.ExternalMetas["style"] = markup.IssueNameStyleAlphanumeric
default:
- repo.ExternalMetas["style"] = markdown.IssueNameStyleNumeric
+ repo.ExternalMetas["style"] = markup.IssueNameStyleNumeric
}
}
@@ -708,7 +708,7 @@ func (repo *Repository) DescriptionHTML() template.HTML {
sanitize := func(s string) string {
return fmt.Sprintf(`<a href="%[1]s" target="_blank" rel="noopener">%[1]s</a>`, s)
}
- return template.HTML(descPattern.ReplaceAllStringFunc(markdown.Sanitize(repo.Description), sanitize))
+ return template.HTML(descPattern.ReplaceAllStringFunc(markup.Sanitize(repo.Description), sanitize))
}
// LocalCopyPath returns the local repository copy path
diff --git a/models/repo_test.go b/models/repo_test.go
index c1eb4e2a79..34eaa16c0b 100644
--- a/models/repo_test.go
+++ b/models/repo_test.go
@@ -8,7 +8,7 @@ import (
"path"
"testing"
- "code.gitea.io/gitea/modules/markdown"
+ "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/setting"
"github.com/Unknwon/com"
@@ -39,13 +39,13 @@ func TestRepo(t *testing.T) {
assert.Equal(t, "https://someurl.com/{user}/{repo}/{issue}", metas["format"])
}
- testSuccess(markdown.IssueNameStyleNumeric)
+ testSuccess(markup.IssueNameStyleNumeric)
- externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markdown.IssueNameStyleAlphanumeric
- testSuccess(markdown.IssueNameStyleAlphanumeric)
+ externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markup.IssueNameStyleAlphanumeric
+ testSuccess(markup.IssueNameStyleAlphanumeric)
- externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markdown.IssueNameStyleNumeric
- testSuccess(markdown.IssueNameStyleNumeric)
+ externalTracker.ExternalTrackerConfig().ExternalTrackerStyle = markup.IssueNameStyleNumeric
+ testSuccess(markup.IssueNameStyleNumeric)
}
func TestGetRepositoryCount(t *testing.T) {