@vue/language-service 3.2.8 → 3.2.9
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.
- package/package.json +16 -14
- package/scripts/update-html-data.js +0 -455
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-service",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"data",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"index.d.ts",
|
|
8
|
+
"index.js",
|
|
9
|
+
"lib/**/*.d.ts",
|
|
10
|
+
"lib/**/*.js"
|
|
9
11
|
],
|
|
10
12
|
"sideEffects": false,
|
|
11
13
|
"repository": {
|
|
@@ -18,27 +20,27 @@
|
|
|
18
20
|
},
|
|
19
21
|
"dependencies": {
|
|
20
22
|
"@volar/language-service": "2.4.28",
|
|
21
|
-
"@vue/language-core": "3.2.
|
|
23
|
+
"@vue/language-core": "3.2.9",
|
|
22
24
|
"@vue/shared": "^3.5.0",
|
|
23
25
|
"path-browserify": "^1.0.1",
|
|
24
|
-
"volar-service-css": "0.0.
|
|
25
|
-
"volar-service-emmet": "0.0.
|
|
26
|
-
"volar-service-html": "0.0.
|
|
27
|
-
"volar-service-json": "0.0.
|
|
28
|
-
"volar-service-pug": "0.0.
|
|
29
|
-
"volar-service-pug-beautify": "0.0.
|
|
30
|
-
"volar-service-typescript": "0.0.
|
|
26
|
+
"volar-service-css": "0.0.71",
|
|
27
|
+
"volar-service-emmet": "0.0.71",
|
|
28
|
+
"volar-service-html": "0.0.71",
|
|
29
|
+
"volar-service-json": "0.0.71",
|
|
30
|
+
"volar-service-pug": "0.0.71",
|
|
31
|
+
"volar-service-pug-beautify": "0.0.71",
|
|
32
|
+
"volar-service-typescript": "0.0.71",
|
|
31
33
|
"vscode-html-languageservice": "^5.6.2",
|
|
32
34
|
"vscode-uri": "^3.1.0"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^24.1.0",
|
|
36
38
|
"@types/path-browserify": "^1.0.3",
|
|
37
39
|
"@volar/kit": "2.4.28",
|
|
38
40
|
"@volar/typescript": "2.4.28",
|
|
39
41
|
"@vue/compiler-dom": "^3.5.0",
|
|
40
|
-
"@vue/typescript-plugin": "3.2.
|
|
42
|
+
"@vue/typescript-plugin": "3.2.9",
|
|
41
43
|
"vscode-css-languageservice": "^6.3.10"
|
|
42
44
|
},
|
|
43
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9c1fd47ffe25e86394232dfc76453a5f76cb4fe0"
|
|
44
46
|
}
|
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const langs = [
|
|
5
|
-
{
|
|
6
|
-
name: 'en',
|
|
7
|
-
url: 'https://vuejs.org/',
|
|
8
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs/docs/',
|
|
9
|
-
supported: true,
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: 'zh-cn',
|
|
13
|
-
url: 'https://cn.vuejs.org/',
|
|
14
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-zh-cn/',
|
|
15
|
-
supported: true,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: 'zh-hk',
|
|
19
|
-
url: 'https://zh-hk.vuejs.org/',
|
|
20
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-zh-hk/',
|
|
21
|
-
supported: true,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'ja',
|
|
25
|
-
url: 'https://ja.vuejs.org/',
|
|
26
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-ja/',
|
|
27
|
-
supported: true,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'ua',
|
|
31
|
-
url: 'https://ua.vuejs.org/',
|
|
32
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-ua/',
|
|
33
|
-
supported: false,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: 'fr',
|
|
37
|
-
url: 'https://fr.vuejs.org/',
|
|
38
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-fr/',
|
|
39
|
-
supported: true,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'ko',
|
|
43
|
-
url: 'https://ko.vuejs.org/',
|
|
44
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-ko/',
|
|
45
|
-
supported: true,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'pt',
|
|
49
|
-
url: 'https://pt.vuejs.org/',
|
|
50
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-pt/',
|
|
51
|
-
supported: true,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'bn',
|
|
55
|
-
url: 'https://bn.vuejs.org/',
|
|
56
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-bn/',
|
|
57
|
-
supported: false,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'it',
|
|
61
|
-
url: 'https://it.vuejs.org/',
|
|
62
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-it/',
|
|
63
|
-
supported: true,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'cs',
|
|
67
|
-
url: 'https://cs.vuejs.org/',
|
|
68
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-cs/',
|
|
69
|
-
supported: true,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'ru',
|
|
73
|
-
url: 'https://ru.vuejs.org/',
|
|
74
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-ru/',
|
|
75
|
-
supported: true,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'fa',
|
|
79
|
-
url: 'https://fa.vuejs.org/',
|
|
80
|
-
repoUrl: 'https://raw.githubusercontent.com/vuejs-translations/docs-fa/',
|
|
81
|
-
supported: false,
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
localeWorker();
|
|
86
|
-
for (const lang of langs) {
|
|
87
|
-
if (lang.supported) {
|
|
88
|
-
templateWorker(lang);
|
|
89
|
-
sfcWorker(lang);
|
|
90
|
-
modelWorker(lang);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function localeWorker() {
|
|
95
|
-
const data = langs.map(({ name, url }) => ({ name, url }));
|
|
96
|
-
|
|
97
|
-
const writePath = path.resolve(__dirname, '../data/locale.json');
|
|
98
|
-
fs.writeFileSync(writePath, JSON.stringify(data, null, 2));
|
|
99
|
-
console.log(writePath);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function sfcWorker(lang) {
|
|
103
|
-
const sfcDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/sfc-spec.md', lang.url);
|
|
104
|
-
const cssFeaturesDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/sfc-css-features.md', lang.url);
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @type {import('vscode-html-languageservice').IAttributeData}
|
|
108
|
-
*/
|
|
109
|
-
const langAttr = {
|
|
110
|
-
name: 'lang',
|
|
111
|
-
description: {
|
|
112
|
-
kind: 'markdown',
|
|
113
|
-
value: sfcDoc.split('\n## ')[4].split('\n').slice(1).join('\n').trim(),
|
|
114
|
-
},
|
|
115
|
-
values: [
|
|
116
|
-
// // custom block
|
|
117
|
-
// { name: 'md' },
|
|
118
|
-
// { name: 'json' },
|
|
119
|
-
// { name: 'jsonc' },
|
|
120
|
-
// { name: 'json5' },
|
|
121
|
-
// { name: 'yaml' },
|
|
122
|
-
// { name: 'toml' },
|
|
123
|
-
// { name: 'gql' },
|
|
124
|
-
// { name: 'graphql' },
|
|
125
|
-
],
|
|
126
|
-
references: 'api/sfc-spec.html#pre-processors',
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* @type {import('vscode-html-languageservice').IAttributeData}
|
|
130
|
-
*/
|
|
131
|
-
const srcAttr = {
|
|
132
|
-
name: 'src',
|
|
133
|
-
description: {
|
|
134
|
-
kind: 'markdown',
|
|
135
|
-
value: sfcDoc.split('\n## ')[5].split('\n').slice(1).join('\n').trim(),
|
|
136
|
-
},
|
|
137
|
-
references: 'api/sfc-spec.html#src-imports',
|
|
138
|
-
};
|
|
139
|
-
const languageBlocks = sfcDoc
|
|
140
|
-
.split('\n## ')[2]
|
|
141
|
-
.split('\n### ')
|
|
142
|
-
.slice(1)
|
|
143
|
-
.map(section => {
|
|
144
|
-
const lines = section.split('\n');
|
|
145
|
-
const name = normalizeTagName(lines[0]);
|
|
146
|
-
/**
|
|
147
|
-
* @type {import('vscode-html-languageservice').ITagData}
|
|
148
|
-
*/
|
|
149
|
-
const data = {
|
|
150
|
-
name,
|
|
151
|
-
attributes: name === 'script setup' ? [] : [srcAttr],
|
|
152
|
-
description: {
|
|
153
|
-
kind: 'markdown',
|
|
154
|
-
value: lines.slice(1).join('\n'),
|
|
155
|
-
},
|
|
156
|
-
references: `api/sfc-spec.html#${normalizeHash(name)}`,
|
|
157
|
-
};
|
|
158
|
-
if (name === 'template') {
|
|
159
|
-
data.attributes.push({
|
|
160
|
-
...langAttr,
|
|
161
|
-
values: [
|
|
162
|
-
{ name: 'html' },
|
|
163
|
-
{ name: 'pug' },
|
|
164
|
-
],
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
if (name === 'script') {
|
|
168
|
-
data.attributes.push({
|
|
169
|
-
...langAttr,
|
|
170
|
-
values: [
|
|
171
|
-
{ name: 'ts' },
|
|
172
|
-
{ name: 'js' },
|
|
173
|
-
{ name: 'tsx' },
|
|
174
|
-
{ name: 'jsx' },
|
|
175
|
-
],
|
|
176
|
-
});
|
|
177
|
-
data.attributes.push({ name: 'generic' });
|
|
178
|
-
}
|
|
179
|
-
if (name === 'style') {
|
|
180
|
-
data.attributes.push({
|
|
181
|
-
...langAttr,
|
|
182
|
-
values: [
|
|
183
|
-
{ name: 'css' },
|
|
184
|
-
{ name: 'scss' },
|
|
185
|
-
{ name: 'less' },
|
|
186
|
-
{ name: 'stylus' },
|
|
187
|
-
{ name: 'postcss' },
|
|
188
|
-
{ name: 'sass' },
|
|
189
|
-
],
|
|
190
|
-
});
|
|
191
|
-
data.attributes.push({
|
|
192
|
-
name: 'scoped',
|
|
193
|
-
valueSet: 'v',
|
|
194
|
-
description: {
|
|
195
|
-
kind: 'markdown',
|
|
196
|
-
value: cssFeaturesDoc.split('\n## ')[1].split('\n').slice(1).join('\n').trim(),
|
|
197
|
-
},
|
|
198
|
-
references: 'api/sfc-css-features.html#scoped-css',
|
|
199
|
-
});
|
|
200
|
-
data.attributes.push({
|
|
201
|
-
name: 'module',
|
|
202
|
-
valueSet: 'v',
|
|
203
|
-
description: {
|
|
204
|
-
kind: 'markdown',
|
|
205
|
-
value: cssFeaturesDoc.split('\n## ')[2].split('\n').slice(1).join('\n').trim(),
|
|
206
|
-
},
|
|
207
|
-
references: 'api/sfc-css-features.html#css-modules',
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return data;
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
const scriptBlock = languageBlocks.find(b => b.name === 'script');
|
|
214
|
-
const scriptSetupBlock = languageBlocks.find(b => b.name === 'script setup');
|
|
215
|
-
|
|
216
|
-
if (!scriptBlock || !scriptSetupBlock) {
|
|
217
|
-
throw new Error('script or script setup block not found');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
scriptBlock.attributes.push({
|
|
221
|
-
name: 'setup',
|
|
222
|
-
valueSet: 'v',
|
|
223
|
-
description: scriptSetupBlock.description,
|
|
224
|
-
references: scriptSetupBlock.references,
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* @type {import('vscode-html-languageservice').HTMLDataV1}
|
|
229
|
-
*/
|
|
230
|
-
const data = {
|
|
231
|
-
version: 1.1,
|
|
232
|
-
tags: languageBlocks,
|
|
233
|
-
globalAttributes: [langAttr, srcAttr],
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
const writePath = path.resolve(__dirname, '../data/language-blocks/' + lang.name + '.json');
|
|
237
|
-
fs.writeFileSync(writePath, JSON.stringify(data, null, 2));
|
|
238
|
-
console.log(writePath);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
async function modelWorker(lang) {
|
|
242
|
-
const formsDoc = await fetchText(lang.repoUrl + 'HEAD/src/guide/essentials/forms.md', lang.url);
|
|
243
|
-
const modifiers = formsDoc
|
|
244
|
-
.split('\n## ')[3]
|
|
245
|
-
.split('\n### ')
|
|
246
|
-
.slice(1)
|
|
247
|
-
.map(section => {
|
|
248
|
-
const lines = section.split('\n');
|
|
249
|
-
let name = normalizeAttrName(lines[0]);
|
|
250
|
-
name = name.split('.')[1];
|
|
251
|
-
/**
|
|
252
|
-
* @type {import('vscode-html-languageservice').IAttributeData}
|
|
253
|
-
*/
|
|
254
|
-
const data = {
|
|
255
|
-
name,
|
|
256
|
-
description: {
|
|
257
|
-
kind: 'markdown',
|
|
258
|
-
value: lines.slice(1).join('\n').trim(),
|
|
259
|
-
},
|
|
260
|
-
references: `guide/essentials/forms.html#${normalizeHash(name)}`,
|
|
261
|
-
};
|
|
262
|
-
return data;
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* @type {import('vscode-html-languageservice').HTMLDataV1}
|
|
267
|
-
*/
|
|
268
|
-
const data = {
|
|
269
|
-
version: 1.1,
|
|
270
|
-
globalAttributes: modifiers,
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const writePath = path.resolve(__dirname, '../data/model-modifiers/' + lang.name + '.json');
|
|
274
|
-
fs.writeFileSync(writePath, JSON.stringify(data, null, 2));
|
|
275
|
-
console.log(writePath);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
async function templateWorker(lang) {
|
|
279
|
-
const componentsDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-components.md', lang.url);
|
|
280
|
-
const elementsDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-special-elements.md', lang.url);
|
|
281
|
-
const directivesDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-directives.md', lang.url);
|
|
282
|
-
const attributesDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/built-in-special-attributes.md', lang.url);
|
|
283
|
-
const ssrDoc = await fetchText(lang.repoUrl + 'HEAD/src/api/ssr.md', lang.url);
|
|
284
|
-
|
|
285
|
-
const components = componentsDoc
|
|
286
|
-
.split('\n## ')
|
|
287
|
-
.slice(1)
|
|
288
|
-
.map(section => {
|
|
289
|
-
const lines = section.split('\n');
|
|
290
|
-
const name = normalizeTagName(lines[0]);
|
|
291
|
-
/**
|
|
292
|
-
* @type {import('vscode-html-languageservice').ITagData}
|
|
293
|
-
*/
|
|
294
|
-
const data = {
|
|
295
|
-
name,
|
|
296
|
-
description: {
|
|
297
|
-
kind: 'markdown',
|
|
298
|
-
value: lines.slice(1).join('\n'),
|
|
299
|
-
},
|
|
300
|
-
attributes: [],
|
|
301
|
-
references: `api/built-in-components.html#${normalizeHash(name)}`,
|
|
302
|
-
};
|
|
303
|
-
return data;
|
|
304
|
-
});
|
|
305
|
-
const elements = elementsDoc
|
|
306
|
-
.split('\n## ')
|
|
307
|
-
.slice(1)
|
|
308
|
-
.map(section => {
|
|
309
|
-
const lines = section.split('\n');
|
|
310
|
-
const name = normalizeTagName(lines[0]);
|
|
311
|
-
/**
|
|
312
|
-
* @type {import('vscode-html-languageservice').ITagData}
|
|
313
|
-
*/
|
|
314
|
-
const data = {
|
|
315
|
-
name,
|
|
316
|
-
description: {
|
|
317
|
-
kind: 'markdown',
|
|
318
|
-
value: lines.slice(1).join('\n'),
|
|
319
|
-
},
|
|
320
|
-
attributes: [],
|
|
321
|
-
references: `api/built-in-special-elements.html#${normalizeHash(name)}`,
|
|
322
|
-
};
|
|
323
|
-
return data;
|
|
324
|
-
});
|
|
325
|
-
const directives = directivesDoc
|
|
326
|
-
.split('\n## ')
|
|
327
|
-
.slice(1)
|
|
328
|
-
.map(section => {
|
|
329
|
-
const lines = section.split('\n');
|
|
330
|
-
const name = normalizeAttrName(lines[0]);
|
|
331
|
-
/**
|
|
332
|
-
* @type {import('vscode-html-languageservice').IAttributeData}
|
|
333
|
-
*/
|
|
334
|
-
const data = {
|
|
335
|
-
name,
|
|
336
|
-
valueSet: name === 'v-cloak'
|
|
337
|
-
|| name === 'v-else'
|
|
338
|
-
|| name === 'v-once'
|
|
339
|
-
|| name === 'v-pre'
|
|
340
|
-
? 'v'
|
|
341
|
-
: undefined,
|
|
342
|
-
description: {
|
|
343
|
-
kind: 'markdown',
|
|
344
|
-
value: lines.slice(1).join('\n').trim(),
|
|
345
|
-
},
|
|
346
|
-
references: `api/built-in-directives.html#${normalizeHash(name)}`,
|
|
347
|
-
};
|
|
348
|
-
return data;
|
|
349
|
-
});
|
|
350
|
-
const attributes = attributesDoc
|
|
351
|
-
.split('\n## ')
|
|
352
|
-
.slice(1)
|
|
353
|
-
.map(section => {
|
|
354
|
-
const lines = section.split('\n');
|
|
355
|
-
const name = normalizeAttrName(lines[0]);
|
|
356
|
-
/**
|
|
357
|
-
* @type {import('vscode-html-languageservice').IAttributeData}
|
|
358
|
-
*/
|
|
359
|
-
const data = {
|
|
360
|
-
name,
|
|
361
|
-
description: {
|
|
362
|
-
kind: 'markdown',
|
|
363
|
-
value: lines.slice(1).join('\n').trim(),
|
|
364
|
-
},
|
|
365
|
-
references: `api/built-in-special-attributes.html#${normalizeHash(name)}`,
|
|
366
|
-
};
|
|
367
|
-
return data;
|
|
368
|
-
});
|
|
369
|
-
const dataAllowMismatch = ssrDoc
|
|
370
|
-
.split(/## data-allow-mismatch.*\n/)
|
|
371
|
-
.slice(1)
|
|
372
|
-
.map(section => {
|
|
373
|
-
const lines = section.split('\n');
|
|
374
|
-
const name = 'data-allow-mismatch';
|
|
375
|
-
/**
|
|
376
|
-
* @type {import('vscode-html-languageservice').IAttributeData}
|
|
377
|
-
*/
|
|
378
|
-
const data = {
|
|
379
|
-
name,
|
|
380
|
-
description: {
|
|
381
|
-
kind: 'markdown',
|
|
382
|
-
value: lines.slice(1).join('\n'),
|
|
383
|
-
},
|
|
384
|
-
references: `api/ssr.html#${normalizeHash(name)}`,
|
|
385
|
-
};
|
|
386
|
-
return data;
|
|
387
|
-
})[0];
|
|
388
|
-
|
|
389
|
-
if (dataAllowMismatch) {
|
|
390
|
-
attributes.push(dataAllowMismatch);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* @type {import('vscode-html-languageservice').HTMLDataV1}
|
|
395
|
-
*/
|
|
396
|
-
const data = {
|
|
397
|
-
version: 1.1,
|
|
398
|
-
tags: [
|
|
399
|
-
...components,
|
|
400
|
-
...elements,
|
|
401
|
-
],
|
|
402
|
-
globalAttributes: [
|
|
403
|
-
...directives,
|
|
404
|
-
...attributes,
|
|
405
|
-
],
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
const writePath = path.resolve(__dirname, '../data/template/' + lang.name + '.json');
|
|
409
|
-
fs.writeFileSync(writePath, JSON.stringify(data, null, 2));
|
|
410
|
-
console.log(writePath);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
async function fetchText(url, baseUrl) {
|
|
414
|
-
let text = await (await fetch(url)).text();
|
|
415
|
-
text = text.replace(/```vue-html/g, '```html');
|
|
416
|
-
text = text.replace(/\{#.*?\}/g, '');
|
|
417
|
-
text = resolveMarkdownLinks(text, baseUrl);
|
|
418
|
-
return text;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
function resolveMarkdownLinks(text, url) {
|
|
422
|
-
return text.replace(/\[(.*?)\]\(\/(.*?)\)/g, (match, p1, p2) => {
|
|
423
|
-
const p2Parts = p2.split('#');
|
|
424
|
-
if (!p2Parts[0].endsWith('.html')) {
|
|
425
|
-
p2Parts[0] += '.html';
|
|
426
|
-
}
|
|
427
|
-
p2 = p2Parts.join('#');
|
|
428
|
-
return `[${p1}](${url}${p2})`;
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
function normalizeTagName(name) {
|
|
433
|
-
name = name.trim();
|
|
434
|
-
return _normalizeName(name);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function normalizeAttrName(name) {
|
|
438
|
-
name = name.trim();
|
|
439
|
-
name = name.split(' ')[0];
|
|
440
|
-
return _normalizeName(name);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function _normalizeName(name) {
|
|
444
|
-
if (name.startsWith('`')) {
|
|
445
|
-
name = name.split('`')[1].split('`')[0];
|
|
446
|
-
}
|
|
447
|
-
if (name.startsWith('<')) {
|
|
448
|
-
name = name.split('<')[1].split('>')[0];
|
|
449
|
-
}
|
|
450
|
-
return name;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
function normalizeHash(str) {
|
|
454
|
-
return str.replace(/ /g, '-').toLowerCase();
|
|
455
|
-
}
|