@cnbcool/cnb-api-generate 2.3.3 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { loadPlugin } from "./plugins";
|
|
2
|
+
|
|
1
3
|
export async function fetchResponseHandler(fetchOriginParams: Record<string, any>, response: {
|
|
2
4
|
status: number,
|
|
3
5
|
trace?: string,
|
|
@@ -27,7 +29,7 @@ export async function fetchResponseHandler(fetchOriginParams: Record<string, any
|
|
|
27
29
|
if (convertConfig) {
|
|
28
30
|
const {converter, handler} = convertConfig;
|
|
29
31
|
try {
|
|
30
|
-
const converterExample =
|
|
32
|
+
const converterExample = loadPlugin(converter);
|
|
31
33
|
if (converterExample && typeof converterExample === 'function') {
|
|
32
34
|
return handler(converterExample, fetchOriginParams, response.data);
|
|
33
35
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CONVER_LINK = 'convert-link'
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export default function convertLink(text: string, repoSlug: string | undefined, branchOrSha: string | undefined) {
|
|
11
11
|
// 查询所有代码块的位置
|
|
12
|
-
let codeBlockPositions = [];
|
|
12
|
+
let codeBlockPositions: number[] = [];
|
|
13
13
|
let index = 0;
|
|
14
14
|
while (index !== -1) {
|
|
15
15
|
const nextIndex = text.indexOf('```', index);
|
|
@@ -22,7 +22,7 @@ export default function convertLink(text: string, repoSlug: string | undefined,
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// 查询所有行内代码块的位置
|
|
25
|
-
let inlineCodeBlockPositions = [];
|
|
25
|
+
let inlineCodeBlockPositions: number[] = [];
|
|
26
26
|
index = 0;
|
|
27
27
|
while (index < text.length) {
|
|
28
28
|
const nextIndex = text.indexOf('`', index);
|
|
@@ -58,7 +58,7 @@ export default function convertLink(text: string, repoSlug: string | undefined,
|
|
|
58
58
|
let match;
|
|
59
59
|
|
|
60
60
|
// Collect all replacements with their positions
|
|
61
|
-
const replacements = [];
|
|
61
|
+
const replacements: { start: number; end: number; newUrl: string }[] = [];
|
|
62
62
|
|
|
63
63
|
// Match markdown links and images: [alt](url), [](url),  and 
|
|
64
64
|
const markdownLinkRegex = /!?\[([^\]]*)\]\(([^)]+)\)/g;
|