@@ -47,6 +47,36 @@ const reduceHeadings = (text) => text
47
47
. replace ( / ^ # # # \s + ( .+ ) $ / gm, '**__$1__**' ) // Convert H3 to bold + underline
48
48
. replace ( / ^ # # \s + ( .+ ) $ / gm, '**$1**' ) ; // Convert H2 to bold
49
49
50
+ /**
51
+ * Converts PR links, issue links, and changelog links to markdown format.
52
+ * - PR links: `https://github.com/OWNER/REPO/pull/1` -> `[PR #1](https://github.com/OWNER/REPO/pull/1)`
53
+ * - Issue links: `https://github.com/OWNER/REPO/issues/1` -> `[Issue #30](https://github.com/OWNER/REPO/issues/1)`
54
+ * - Changelog links: `https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0` -> `[v1.0.0...v1.1.0](https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0)`
55
+ * @param {string } text The input text.
56
+ * @returns {string } The text with links converted to markdown format.
57
+ */
58
+ const convertLinksToMarkdown = ( text ) => {
59
+ // Convert PR links
60
+ text = text . replace (
61
+ / h t t p s : \/ \/ g i t h u b \. c o m \/ ( [ \w - ] + ) \/ ( [ \w - ] + ) \/ p u l l \/ ( \d + ) / g,
62
+ ( match , owner , repo , prNumber ) => `[PR #${ prNumber } ](${ match } )`
63
+ ) ;
64
+
65
+ // Convert issue links
66
+ text = text . replace (
67
+ / h t t p s : \/ \/ g i t h u b \. c o m \/ ( [ \w - ] + ) \/ ( [ \w - ] + ) \/ i s s u e s \/ ( \d + ) / g,
68
+ ( match , owner , repo , issueNumber ) => `[Issue #${ issueNumber } ](${ match } )`
69
+ ) ;
70
+
71
+ // Convert changelog comparison links
72
+ text = text . replace (
73
+ / h t t p s : \/ \/ g i t h u b \. c o m \/ ( [ \w - ] + ) \/ ( [ \w - ] + ) \/ c o m p a r e \/ ( [ v \w . - ] + ) \. \. \. ( [ v \w . - ] + ) / g,
74
+ ( match , owner , repo , fromVersion , toVersion ) => `[${ fromVersion } ...${ toVersion } ](${ match } )`
75
+ ) ;
76
+
77
+ return text ;
78
+ } ;
79
+
50
80
/**
51
81
* Stylizes a markdown body into an appropriate embed message style.
52
82
* @param {string } description The description to format.
@@ -57,6 +87,7 @@ const formatDescription = (description) => {
57
87
edit = removeHTMLComments ( edit ) ;
58
88
edit = reduceNewlines ( edit ) ;
59
89
edit = convertMentionsToLinks ( edit ) ;
90
+ edit = convertLinksToMarkdown ( edit ) ;
60
91
edit = edit . trim ( ) ;
61
92
62
93
if ( core . getBooleanInput ( 'reduce_headings' ) ) {
0 commit comments