-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99a5b56
commit ad5ec2d
Showing
15 changed files
with
94 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare const replace: (text: string, match: Array<string>, to: string) => string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const replace = (text, match, to) => { | ||
return text.replace(match[0], to); | ||
// const index: number = match['index'] | ||
// const from: string = match[0] | ||
// | ||
// return text.slice(0, index) + to + text.slice(index + from.length) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { GitHubLinkifyTransformer } from '../../types/transformer.js'; | ||
export declare const blobsCompact: GitHubLinkifyTransformer; | ||
export declare const blobsExpand: GitHubLinkifyTransformer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { replace } from '../helpers.js'; | ||
import { template } from '../template.js'; | ||
import { regex } from '../regex'; | ||
import { url } from '../url'; | ||
export const blobsCompact = (text, repo) => { | ||
const replacer = (value, item) => replace(value, item, template('blob', `${item[1]}/${item[2]}`, item[3])); | ||
text = regex(text, /\[[\w\d\s`]+]\(https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/blob\/([\w\d\/\.\-_]+)\)/g, replacer); | ||
text = regex(text, /https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/blob\/([\w\d\/\.\-_]+)/g, replacer); | ||
return text; | ||
}; | ||
export const blobsExpand = (text, repo) => { | ||
const replacer = (value, item) => value.replace(item[0], url(repo, `${item[1].includes(repo) ? '' : item[1] + '#'}${item[2]}`, `${item[1]}/blob/${item[2]}`)); | ||
text = regex(text, /::blob::([\w\d\-_\/]+)::([\w\d\/\.\-_]+)::/g, replacer); | ||
return text; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { regex } from '../regex.js'; | ||
import { replace } from '../helpers.js'; | ||
import { template } from '../template.js'; | ||
import { url } from '../url.js'; | ||
export const pullRequestCompact = (text, repo) => { | ||
const replacerFull = (value, item) => value.replace(item[0], template('pull_request', `${item[1]}/${item[2]}`, item[3])); | ||
const replacerShort = (value, item) => value.replace(item[0], template('pull_request', repo, item[1])); | ||
const replacerFull = (value, item) => replace(value, item, template('pull_request', `${item[1]}/${item[2]}`, item[3])); | ||
const replacerShort = (value, item) => replace(value, item, template('pull_request', repo, item[1])); | ||
text = regex(text, /\[[\s`#@]*\d+]\(https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/pull\/(\d+)\)/g, replacerFull); | ||
text = regex(text, /https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/pull\/(\d+)/g, replacerFull); | ||
text = regex(text, /#(\d+)/g, replacerShort); | ||
return text; | ||
}; | ||
export const pullRequestExpand = (text, repo) => { | ||
const replacer = (value, item) => value.replace(item[0], url(repo, `${item[1]}#${item[2]}`, `${item[1]}/pull/${item[2]}`)); | ||
text = regex(text, /::pull_request::([\w\d\-_\/]+)::([\w\d\-_]+)::/g, replacer); | ||
text = regex(text, /::pull_request::([\d\w.\-_\/]+)::([\d\w.\-_\/]+)::/g, replacer); | ||
return text; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { GitHubLinkifyTransformer } from '../../types/transformer.js'; | ||
export declare const tagsCompact: GitHubLinkifyTransformer; | ||
export declare const tagsExpand: GitHubLinkifyTransformer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { regex } from '../regex.js'; | ||
import { replace } from '../helpers.js'; | ||
import { template } from '../template.js'; | ||
import { url } from '../url.js'; | ||
export const tagsCompact = (text, repo) => { | ||
const replacerFull = (value, item) => replace(value, item, template('tag', `${item[1]}/${item[2]}`, item[3])); | ||
const replacerShort = (value, item) => replace(value, item, template('tag', repo, item[1])); | ||
text = regex(text, /\[[\s\w\d`.\-]+]\(https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/releases\/tag\/(v?\d+\.\d+\.\d+-?\w*\.?\d*)\)/g, replacerFull); | ||
text = regex(text, /https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/releases\/tag\/(v?\d+\.\d+\.\d+-?\w*\.?\d*)/g, replacerFull); | ||
// text = regex(text, /(?<!:)(?<=^|\s)(v?\d+\.\d+\.\d+-?\w*\.?\d*)(?<!:)/g, replacerShort) | ||
return text; | ||
}; | ||
export const tagsExpand = (text, repo) => { | ||
const replacer = (value, item) => value.replace(item[0], url(repo, `${item[1].includes(repo) ? '' : item[1] + '#'}${item[2].replace('v', '')}`, `${item[1]}/releases/tag/${item[2]}`)); | ||
text = regex(text, /::tag::([\w\d.\-\/]+)::([\w\d.\-]+)::/g, replacer); | ||
return text; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { GitHubLinkifyTransformer } from '../../types/transformer.js'; | ||
export declare const treesCompact: GitHubLinkifyTransformer; | ||
export declare const treesExpand: GitHubLinkifyTransformer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { regex } from '../regex.js'; | ||
import { replace } from '../helpers.js'; | ||
import { template } from '../template.js'; | ||
import { url } from '../url.js'; | ||
export const treesCompact = (text, repo) => { | ||
const replacer = (value, item) => replace(value, item, template('tree', `${item[1]}/${item[2]}`, `${item[3]}`)); | ||
text = regex(text, /\[[\s`#@]*\d+]\(https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/tree\/([\d\w.\-_\/]+)\)/g, replacer); | ||
text = regex(text, /https:\/\/github\.com\/([\w\d\-_]+)\/([\w\d\-_]+)\/tree\/([\d\w.\-_\/]+)/g, replacer); | ||
return text; | ||
}; | ||
export const treesExpand = (text, repo) => { | ||
const replacer = (value, item) => replace(value, item, url(repo, `${item[1].includes(repo) ? '' : item[1] + '#'}${item[2]}`, `${item[1]}/tree/${item[2]}`)); | ||
text = regex(text, /::tree::([\d\w.\-_\/]+)::([\d\w.\-_\/]+)::/g, replacer); | ||
return text; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const url = (repo, value, link) => { | ||
link = (link || value).replace('https://github.com/', ''); | ||
value = value.replace(repo + '/', '').replace(repo, ''); | ||
return `<a href="https://github.com/${link}" target="_blank" rel="noopener noreferrer">${value} <ExternalLinkIcon /></a>`; | ||
value = value.replace(repo + '/', '').replace(repo, '').trim(); | ||
return `<a href="https://github.com/${link}" target="_blank" rel="noopener noreferrer">${value}<ExternalLinkIcon /></a>`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters