Skip to content

Commit 7bec119

Browse files
committed
Make cross-reference issue and pr links work in markdown documents again
1 parent 250f993 commit 7bec119

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

modules/markup/html.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,10 @@ func fullIssuePatternProcessor(ctx *RenderContext, node *html.Node) {
852852
}
853853

854854
func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
855-
if ctx.Metas == nil || ctx.Metas["mode"] == "document" {
855+
if ctx.Metas == nil {
856856
return
857857
}
858+
crossLinkOnly := ctx.Metas["mode"] == "document"
858859
var (
859860
found bool
860861
ref *references.RenderizableReference
@@ -868,7 +869,7 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
868869
// Repos with external issue trackers might still need to reference local PRs
869870
// We need to concern with the first one that shows up in the text, whichever it is
870871
isNumericStyle := ctx.Metas["style"] == "" || ctx.Metas["style"] == IssueNameStyleNumeric
871-
foundNumeric, refNumeric := references.FindRenderizableReferenceNumeric(node.Data, hasExtTrackFormat && !isNumericStyle)
872+
foundNumeric, refNumeric := references.FindRenderizableReferenceNumeric(node.Data, hasExtTrackFormat && !isNumericStyle, crossLinkOnly)
872873

873874
switch ctx.Metas["style"] {
874875
case "", IssueNameStyleNumeric:

modules/references/references.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,11 @@ func FindAllIssueReferences(content string) []IssueReference {
331331
}
332332

333333
// FindRenderizableReferenceNumeric returns the first unvalidated reference found in a string.
334-
func FindRenderizableReferenceNumeric(content string, prOnly bool) (bool, *RenderizableReference) {
335-
match := issueNumericPattern.FindStringSubmatchIndex(content)
334+
func FindRenderizableReferenceNumeric(content string, prOnly, crossLinkOnly bool) (bool, *RenderizableReference) {
335+
var match []int = nil
336+
if !crossLinkOnly {
337+
match = issueNumericPattern.FindStringSubmatchIndex(content)
338+
}
336339
if match == nil {
337340
if match = crossReferenceIssueNumericPattern.FindStringSubmatchIndex(content); match == nil {
338341
return false, nil

0 commit comments

Comments
 (0)