File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 11import MarkdownIt from "markdown-it" ;
22
3- const REGEX = / # ( \d + ) / g;
3+ const DEFAULT_ORG = "Creators-of-Create" ;
4+ const DEFAULT_REPO = "Create" ;
5+ const REGEX =
6+ / ( [ A - Z a - z 0 - 9 _ . - ] + ) \/ ( [ A - Z a - z 0 - 9 _ . - ] + ) # ( \d + ) | ( [ A - Z a - z 0 - 9 _ . - ] + ) ? # ( \d + ) / g;
47
58export default function ( md : MarkdownIt ) {
69 md . core . ruler . after ( "linkify" , "github-links" , ( state ) => {
@@ -14,7 +17,15 @@ export default function (md: MarkdownIt) {
1417 const text = child . content ;
1518
1619 for ( const match of text . matchAll ( REGEX ) ) {
17- const [ full , number ] = match ;
20+ const [
21+ fullMatch ,
22+ matchedOrg1 ,
23+ matchedRepo1 ,
24+ matchedNum1 ,
25+ matchedOrg2 ,
26+ matchedNum2 ,
27+ ] = match ;
28+ console . log ( match ) ;
1829 const index = match . index ;
1930
2031 if ( index > last ) {
@@ -25,13 +36,17 @@ export default function (md: MarkdownIt) {
2536 } ) ;
2637 }
2738
39+ const org = matchedOrg1 ?? matchedOrg2 ?? DEFAULT_ORG ;
40+ const repo = matchedRepo1 ?? DEFAULT_REPO ;
41+ const number = matchedNum1 ?? matchedNum2 ;
42+
2843 newChildren . push ( {
2944 type : "html_inline" ,
30- content : `<a href="https://github.com/Creators-of-Create/Create /issues/${ number } "># ${ number } </a>` ,
45+ content : `<a href="https://github.com/${ org } / ${ repo } /issues/${ number } ">${ fullMatch } </a>` ,
3146 level : child . level ,
3247 } ) ;
3348
34- last = index + full . length ;
49+ last = index + fullMatch . length ;
3550 }
3651
3752 if ( last < text . length ) {
You can’t perform that action at this time.
0 commit comments