@ -159,9 +159,9 @@ func PostProcessDefault(ctx *RenderContext, input io.Reader, output io.Writer) e
return postProcess ( ctx , procs , input , output )
}
// Render CommitMessage will use the same logic as PostProcess, but will disable
// PostProcess CommitMessage will use the same logic as PostProcess, but will disable
// the shortLinkProcessor.
func Render CommitMessage( ctx * RenderContext , content string ) ( string , error ) {
func PostProcess CommitMessage( ctx * RenderContext , content string ) ( string , error ) {
procs := [ ] processor {
fullIssuePatternProcessor ,
comparePatternProcessor ,
@ -183,11 +183,11 @@ var emojiProcessors = []processor{
emojiProcessor ,
}
// Render CommitMessageSubject will use the same logic as PostProcess and
// Render CommitMessage, but will disable the shortLinkProcessor and
// PostProcess CommitMessageSubject will use the same logic as PostProcess and
// PostProcess CommitMessage, but will disable the shortLinkProcessor and
// emailAddressProcessor, will add a defaultLinkProcessor if defaultLink is set,
// which changes every text node into a link to the passed default link.
func Render CommitMessageSubject( ctx * RenderContext , defaultLink , content string ) ( string , error ) {
func PostProcess CommitMessageSubject( ctx * RenderContext , defaultLink , content string ) ( string , error ) {
procs := [ ] processor {
fullIssuePatternProcessor ,
comparePatternProcessor ,
@ -211,26 +211,20 @@ func RenderCommitMessageSubject(ctx *RenderContext, defaultLink, content string)
return postProcessString ( ctx , procs , content )
}
// RenderIssueTitle to process title on individual issue/pull page
func RenderIssueTitle ( ctx * RenderContext , title string ) ( string , error ) {
// do not render other issue/commit links in an issue's title - which in most cases is already a link.
// PostProcessIssueTitle to process title on individual issue/pull page
func PostProcessIssueTitle ( ctx * RenderContext , title string ) ( string , error ) {
return postProcessString ( ctx , [ ] processor {
issueIndexPatternProcessor ,
commitCrossReferencePatternProcessor ,
hashCurrentPatternProcessor ,
emojiShortCodeProcessor ,
emojiProcessor ,
} , title )
}
func postProcessString ( ctx * RenderContext , procs [ ] processor , content string ) ( string , error ) {
var buf strings . Builder
if err := postProcess ( ctx , procs , strings . NewReader ( content ) , & buf ) ; err != nil {
return "" , err
}
return buf . String ( ) , nil
}
// RenderDescriptionHTML will use similar logic as PostProcess, but will
// PostProcessDescriptionHTML will use similar logic as PostProcess, but will
// use a single special linkProcessor.
func Render DescriptionHTML( ctx * RenderContext , content string ) ( string , error ) {
func PostProcessDescriptionHTML ( ctx * RenderContext , content string ) ( string , error ) {
return postProcessString ( ctx , [ ] processor {
descriptionLinkProcessor ,
emojiShortCodeProcessor ,
@ -238,13 +232,24 @@ func RenderDescriptionHTML(ctx *RenderContext, content string) (string, error) {
} , content )
}
// Render Emoji for when we want to just process emoji and shortcodes
// PostProcess Emoji for when we want to just process emoji and shortcodes
// in various places it isn't already run through the normal markdown processor
func Render Emoji( ctx * RenderContext , content string ) ( string , error ) {
func PostProcess Emoji( ctx * RenderContext , content string ) ( string , error ) {
return postProcessString ( ctx , emojiProcessors , content )
}
func postProcessString ( ctx * RenderContext , procs [ ] processor , content string ) ( string , error ) {
var buf strings . Builder
if err := postProcess ( ctx , procs , strings . NewReader ( content ) , & buf ) ; err != nil {
return "" , err
}
return buf . String ( ) , nil
}
func postProcess ( ctx * RenderContext , procs [ ] processor , input io . Reader , output io . Writer ) error {
if ! ctx . usedByRender && ctx . RenderHelper != nil {
defer ctx . RenderHelper . CleanUp ( )
}
// FIXME: don't read all content to memory
rawHTML , err := io . ReadAll ( input )
if err != nil {