@ -161,6 +161,7 @@ func NewFuncMap() []template.FuncMap {
"RenderCommitMessageLink" : RenderCommitMessageLink ,
"RenderCommitMessageLink" : RenderCommitMessageLink ,
"RenderCommitMessageLinkSubject" : RenderCommitMessageLinkSubject ,
"RenderCommitMessageLinkSubject" : RenderCommitMessageLinkSubject ,
"RenderCommitBody" : RenderCommitBody ,
"RenderCommitBody" : RenderCommitBody ,
"RenderCodeBlock" : RenderCodeBlock ,
"RenderIssueTitle" : RenderIssueTitle ,
"RenderIssueTitle" : RenderIssueTitle ,
"RenderEmoji" : RenderEmoji ,
"RenderEmoji" : RenderEmoji ,
"RenderEmojiPlain" : emoji . ReplaceAliases ,
"RenderEmojiPlain" : emoji . ReplaceAliases ,
@ -795,6 +796,16 @@ func RenderCommitBody(ctx context.Context, msg, urlPrefix string, metas map[stri
return template . HTML ( renderedMessage )
return template . HTML ( renderedMessage )
}
}
// Match text that is between back ticks.
var codeMatcher = regexp . MustCompile ( "`([^`]+)`" )
// RenderCodeBlock renders "`…`" as highlighted "<code>" block.
// Intended for issue and PR titles, these containers should have styles for "<code>" elements
func RenderCodeBlock ( htmlEscapedTextToRender template . HTML ) template . HTML {
htmlWithCodeTags := codeMatcher . ReplaceAllString ( string ( htmlEscapedTextToRender ) , "<code>$1</code>" ) // replace with HTML <code> tags
return template . HTML ( htmlWithCodeTags )
}
// RenderIssueTitle renders issue/pull title with defined post processors
// RenderIssueTitle renders issue/pull title with defined post processors
func RenderIssueTitle ( ctx context . Context , text , urlPrefix string , metas map [ string ] string ) template . HTML {
func RenderIssueTitle ( ctx context . Context , text , urlPrefix string , metas map [ string ] string ) template . HTML {
renderedText , err := markup . RenderIssueTitle ( & markup . RenderContext {
renderedText , err := markup . RenderIssueTitle ( & markup . RenderContext {