summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/markup/html.go19
-rw-r--r--modules/templates/helper.go11
-rw-r--r--templates/repo/issue/view_title.tmpl2
3 files changed, 31 insertions, 1 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index f5f811b59b..a6c6649cd3 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -268,6 +268,25 @@ func RenderCommitMessageSubject(
return ctx.postProcess(rawHTML)
}
+// RenderIssueTitle to process title on individual issue/pull page
+func RenderIssueTitle(
+ rawHTML []byte,
+ urlPrefix string,
+ metas map[string]string,
+) ([]byte, error) {
+ ctx := &postProcessCtx{
+ metas: metas,
+ urlPrefix: urlPrefix,
+ procs: []processor{
+ issueIndexPatternProcessor,
+ sha1CurrentPatternProcessor,
+ emojiShortCodeProcessor,
+ emojiProcessor,
+ },
+ }
+ return ctx.postProcess(rawHTML)
+}
+
// RenderDescriptionHTML will use similar logic as PostProcess, but will
// use a single special linkProcessor.
func RenderDescriptionHTML(
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index bb7a3476f2..8b96397529 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -154,6 +154,7 @@ func NewFuncMap() []template.FuncMap {
"RenderCommitMessageLink": RenderCommitMessageLink,
"RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject,
"RenderCommitBody": RenderCommitBody,
+ "RenderIssueTitle": RenderIssueTitle,
"RenderEmoji": RenderEmoji,
"RenderEmojiPlain": emoji.ReplaceAliases,
"ReactionToEmoji": ReactionToEmoji,
@@ -630,6 +631,16 @@ func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.H
return template.HTML(renderedMessage)
}
+// RenderIssueTitle renders issue/pull title with defined post processors
+func RenderIssueTitle(text, urlPrefix string, metas map[string]string) template.HTML {
+ renderedText, err := markup.RenderIssueTitle([]byte(template.HTMLEscapeString(text)), urlPrefix, metas)
+ if err != nil {
+ log.Error("RenderIssueTitle: %v", err)
+ return template.HTML("")
+ }
+ return template.HTML(renderedText)
+}
+
// RenderEmoji renders html text with emoji post processors
func RenderEmoji(text string) template.HTML {
renderedText, err := markup.RenderEmoji([]byte(template.HTMLEscapeString(text)))
diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl
index e2a14502f4..0d594b3a5c 100644
--- a/templates/repo/issue/view_title.tmpl
+++ b/templates/repo/issue/view_title.tmpl
@@ -6,7 +6,7 @@
</div>
{{end}}
<h1>
- <span id="issue-title">{{RenderEmoji .Issue.Title}}</span>
+ <span id="issue-title">{{RenderIssueTitle .Issue.Title $.RepoLink $.Repository.ComposeMetas}}</span>
<span class="index">#{{.Issue.Index}}</span>
<div id="edit-title-input" class="ui input" style="display: none">
<input value="{{.Issue.Title}}" maxlength="255">