wikilint 2.29.1 → 2.30.0
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/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -0
- package/dist/base.mjs +1 -0
- package/dist/bin/cli.js +1 -1
- package/dist/bin/config.js +1 -1
- package/dist/index.js +13 -13
- package/dist/lib/document.js +2 -2
- package/dist/lib/element.js +4 -6
- package/dist/lib/lintConfig.js +7 -0
- package/dist/lib/lsp.d.ts +0 -1
- package/dist/lib/lsp.js +2 -5
- package/dist/lib/node.js +6 -8
- package/dist/lib/text.js +52 -9
- package/dist/lib/title.js +1 -1
- package/dist/mixin/attributesParent.js +2 -4
- package/dist/mixin/elementLike.js +2 -4
- package/dist/mixin/gapped.js +0 -2
- package/dist/mixin/hidden.js +1 -3
- package/dist/mixin/noEscape.js +1 -3
- package/dist/mixin/nodeLike.js +2 -4
- package/dist/mixin/padded.js +5 -9
- package/dist/parser/commentAndExt.js +1 -1
- package/dist/parser/quotes.js +6 -6
- package/dist/parser/table.js +1 -2
- package/dist/src/arg.js +1 -3
- package/dist/src/attribute.js +9 -9
- package/dist/src/attributes.d.ts +1 -0
- package/dist/src/attributes.js +10 -3
- package/dist/src/commented.js +0 -1
- package/dist/src/converter.js +1 -2
- package/dist/src/converterFlags.js +1 -1
- package/dist/src/extLink.js +1 -1
- package/dist/src/heading.js +1 -1
- package/dist/src/imageParameter.js +4 -6
- package/dist/src/index.js +1 -1
- package/dist/src/link/base.js +1 -2
- package/dist/src/link/file.js +6 -6
- package/dist/src/link/galleryImage.js +1 -1
- package/dist/src/link/index.js +2 -2
- package/dist/src/link/redirectTarget.js +1 -1
- package/dist/src/magicLink.js +3 -3
- package/dist/src/multiLine/gallery.js +1 -1
- package/dist/src/multiLine/imagemap.js +1 -1
- package/dist/src/multiLine/paramTag.js +1 -1
- package/dist/src/nested.js +1 -1
- package/dist/src/nowiki/comment.js +1 -1
- package/dist/src/nowiki/index.js +2 -2
- package/dist/src/nowiki/list.d.ts +2 -0
- package/dist/src/nowiki/list.js +30 -0
- package/dist/src/nowiki/noinclude.d.ts +2 -0
- package/dist/src/nowiki/noinclude.js +26 -1
- package/dist/src/nowiki/quote.js +1 -1
- package/dist/src/parameter.js +1 -1
- package/dist/src/pre.js +1 -1
- package/dist/src/redirect.js +1 -1
- package/dist/src/syntax.js +1 -1
- package/dist/src/table/base.js +1 -1
- package/dist/src/table/index.js +4 -4
- package/dist/src/table/td.js +5 -5
- package/dist/src/table/trBase.js +2 -4
- package/dist/src/tag/html.js +1 -1
- package/dist/src/tag/index.js +1 -2
- package/dist/src/tagPair/ext.js +1 -1
- package/dist/src/tagPair/include.js +1 -1
- package/dist/src/transclude.js +4 -6
- package/dist/util/html.js +1 -3
- package/i18n/en.json +2 -0
- package/i18n/zh-hans.json +2 -0
- package/i18n/zh-hant.json +2 -0
- package/package.json +21 -21
package/dist/base.d.mts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const stages: {
|
|
|
45
45
|
'list-range': number;
|
|
46
46
|
};
|
|
47
47
|
export type Stage = keyof typeof stages;
|
|
48
|
-
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
48
|
+
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
49
49
|
export declare namespace LintError {
|
|
50
50
|
type Severity = 'error' | 'warning';
|
|
51
51
|
type Rule = typeof rules[number];
|
package/dist/base.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const stages: {
|
|
|
45
45
|
'list-range': number;
|
|
46
46
|
};
|
|
47
47
|
export type Stage = keyof typeof stages;
|
|
48
|
-
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
48
|
+
export declare const rules: readonly ["bold-header", "format-leakage", "fostered-content", "h1", "illegal-attr", "insecure-style", "invalid-gallery", "invalid-imagemap", "invalid-invoke", "invalid-isbn", "invalid-url", "lonely-apos", "lonely-bracket", "lonely-http", "nested-link", "no-arg", "no-duplicate", "no-ignored", "obsolete-attr", "obsolete-tag", "parsing-order", "pipe-like", "syntax-like", "table-layout", "tag-like", "unbalanced-header", "unclosed-comment", "unclosed-quote", "unclosed-table", "unescaped", "unknown-page", "unmatched-tag", "unterminated-url", "url-encoding", "var-anchor", "void-ext", "invalid-css", "invalid-math"];
|
|
49
49
|
export declare namespace LintError {
|
|
50
50
|
type Severity = 'error' | 'warning';
|
|
51
51
|
type Rule = typeof rules[number];
|
package/dist/base.js
CHANGED
package/dist/base.mjs
CHANGED
package/dist/bin/cli.js
CHANGED
|
@@ -282,7 +282,7 @@ if (caching) {
|
|
|
282
282
|
try {
|
|
283
283
|
cache = JSON.parse(fs_1.default.readFileSync(cacheFile, 'utf8'));
|
|
284
284
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
285
|
-
|
|
285
|
+
assert_1.default.ok(typeof cache === 'object' && cache !== null
|
|
286
286
|
&& typeof cache.include === 'object' && cache.include !== null
|
|
287
287
|
&& typeof cache.noinclude === 'object' && cache.noinclude !== null);
|
|
288
288
|
/* eslint-enable @typescript-eslint/no-unnecessary-condition */
|
package/dist/bin/config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -27,34 +27,34 @@ const rootRequire = (file, dir) => require(path_1.default.isAbsolute(file)
|
|
|
27
27
|
/* NOT FOR BROWSER ONLY END */
|
|
28
28
|
let viewOnly = true;
|
|
29
29
|
let lintConfig = (() => {
|
|
30
|
-
LINT: return new lintConfig_1.LintConfiguration();
|
|
30
|
+
LINT: return new lintConfig_1.LintConfiguration();
|
|
31
31
|
})(), i18n;
|
|
32
32
|
const Parser = {
|
|
33
33
|
config: 'default',
|
|
34
34
|
/** @implements */
|
|
35
35
|
get rules() {
|
|
36
|
-
LINT: return base_1.rules;
|
|
36
|
+
LINT: return base_1.rules;
|
|
37
37
|
},
|
|
38
38
|
/** @implements */
|
|
39
39
|
get i18n() {
|
|
40
|
-
LINT: return { ...constants_1.enMsg, ...i18n };
|
|
40
|
+
LINT: return { ...constants_1.enMsg, ...i18n };
|
|
41
41
|
},
|
|
42
42
|
set i18n(data) {
|
|
43
43
|
/* NOT FOR BROWSER ONLY */
|
|
44
|
-
if (typeof data === 'string') {
|
|
44
|
+
if (typeof data === 'string') {
|
|
45
45
|
i18n = rootRequire(data, 'i18n');
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
/* NOT FOR BROWSER ONLY END */
|
|
49
|
-
LINT: i18n = data;
|
|
49
|
+
LINT: i18n = data;
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
/** @implements */
|
|
53
53
|
get lintConfig() {
|
|
54
|
-
LINT: return lintConfig;
|
|
54
|
+
LINT: return lintConfig;
|
|
55
55
|
},
|
|
56
56
|
set lintConfig(config) {
|
|
57
|
-
LINT: lintConfig = new lintConfig_1.LintConfiguration(config);
|
|
57
|
+
LINT: lintConfig = new lintConfig_1.LintConfiguration(config);
|
|
58
58
|
},
|
|
59
59
|
/** @implements */
|
|
60
60
|
get viewOnly() {
|
|
@@ -117,7 +117,7 @@ const Parser = {
|
|
|
117
117
|
},
|
|
118
118
|
/** @implements */
|
|
119
119
|
msg(msg, arg = '') {
|
|
120
|
-
LINT: return msg
|
|
120
|
+
LINT: return msg
|
|
121
121
|
&& (this.i18n[msg] ?? msg).replace('$1', this.msg(arg));
|
|
122
122
|
},
|
|
123
123
|
/** @implements */
|
|
@@ -172,7 +172,7 @@ const Parser = {
|
|
|
172
172
|
maxStage ??= constants_1.MAX_STAGE;
|
|
173
173
|
config ??= this.getConfig();
|
|
174
174
|
let types;
|
|
175
|
-
LINT: {
|
|
175
|
+
LINT: {
|
|
176
176
|
if (typeof maxStage !== 'number') {
|
|
177
177
|
types = Array.isArray(maxStage) ? maxStage : [maxStage];
|
|
178
178
|
maxStage = Math.max(...types.map(t => base_1.stages[t] || constants_1.MAX_STAGE));
|
|
@@ -190,7 +190,7 @@ const Parser = {
|
|
|
190
190
|
catch (e) /* istanbul ignore next */ {
|
|
191
191
|
if (e instanceof Error) {
|
|
192
192
|
const file = path_1.default.join(__dirname, '..', 'errors', new Date().toISOString()), stage = token.getAttribute('stage');
|
|
193
|
-
for (const k
|
|
193
|
+
for (const k of Object.keys(config)) {
|
|
194
194
|
if (k.startsWith('regex') || config[k] instanceof Set) {
|
|
195
195
|
delete config[k];
|
|
196
196
|
}
|
|
@@ -211,7 +211,7 @@ const Parser = {
|
|
|
211
211
|
},
|
|
212
212
|
/** @implements */
|
|
213
213
|
async partialParse(wikitext, watch, include, config = Parser.getConfig()) {
|
|
214
|
-
LSP: {
|
|
214
|
+
LSP: {
|
|
215
215
|
const { Token } = require('./src/index');
|
|
216
216
|
const set = typeof setImmediate === 'function' ? setImmediate : /* istanbul ignore next */ setTimeout, { running } = debug_1.Shadow;
|
|
217
217
|
debug_1.Shadow.running = true;
|
|
@@ -252,7 +252,7 @@ const Parser = {
|
|
|
252
252
|
},
|
|
253
253
|
/** @implements */
|
|
254
254
|
createLanguageService(uri = {}) {
|
|
255
|
-
LSP: {
|
|
255
|
+
LSP: {
|
|
256
256
|
const mod = require('./lib/lsp');
|
|
257
257
|
const { LanguageService, tasks } = mod;
|
|
258
258
|
return tasks.get(uri) ?? new LanguageService(uri);
|
|
@@ -285,7 +285,7 @@ const def = {
|
|
|
285
285
|
/* NOT FOR BROWSER ONLY */
|
|
286
286
|
'fetchConfig',
|
|
287
287
|
]);
|
|
288
|
-
for (const key
|
|
288
|
+
for (const key of Object.keys(Parser)) {
|
|
289
289
|
if (!enumerable.has(key)) {
|
|
290
290
|
def[key] = { enumerable: false };
|
|
291
291
|
}
|
package/dist/lib/document.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.EmbeddedCSSDocument = exports.EmbeddedJSONDocument = exports.stylelint =
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const common_1 = require("@bhsd/common");
|
|
9
9
|
exports.texvcjs = (() => {
|
|
10
|
-
NPM: {
|
|
10
|
+
NPM: {
|
|
11
11
|
try {
|
|
12
12
|
return require('mathoid-texvcjs');
|
|
13
13
|
}
|
|
@@ -72,7 +72,7 @@ exports.htmlData = (() => {
|
|
|
72
72
|
}
|
|
73
73
|
})();
|
|
74
74
|
exports.stylelint = (async () => {
|
|
75
|
-
NPM: {
|
|
75
|
+
NPM: {
|
|
76
76
|
try {
|
|
77
77
|
return (await import('stylelint')).default;
|
|
78
78
|
}
|
package/dist/lib/element.js
CHANGED
|
@@ -102,7 +102,6 @@ let AstElement = (() => {
|
|
|
102
102
|
* @param i position of the child node / 移除位置
|
|
103
103
|
*/
|
|
104
104
|
removeAt(i) {
|
|
105
|
-
// eslint-disable-next-line no-unused-labels
|
|
106
105
|
LSP: return (0, debug_1.setChildNodes)(this, i, 1)[0];
|
|
107
106
|
}
|
|
108
107
|
/**
|
|
@@ -150,7 +149,7 @@ let AstElement = (() => {
|
|
|
150
149
|
}
|
|
151
150
|
/** @private */
|
|
152
151
|
safeReplaceChildren(elements) {
|
|
153
|
-
LSP: {
|
|
152
|
+
LSP: {
|
|
154
153
|
for (let i = this.length - 1; i >= 0; i--) {
|
|
155
154
|
this.removeAt(i);
|
|
156
155
|
}
|
|
@@ -182,7 +181,7 @@ let AstElement = (() => {
|
|
|
182
181
|
* @param index character index / 位置
|
|
183
182
|
*/
|
|
184
183
|
caretPositionFromIndex(index) {
|
|
185
|
-
LSP: {
|
|
184
|
+
LSP: {
|
|
186
185
|
if (index === undefined) {
|
|
187
186
|
return undefined;
|
|
188
187
|
}
|
|
@@ -225,7 +224,7 @@ let AstElement = (() => {
|
|
|
225
224
|
* @param index character index / 位置
|
|
226
225
|
*/
|
|
227
226
|
elementFromIndex(index) {
|
|
228
|
-
LSP: {
|
|
227
|
+
LSP: {
|
|
229
228
|
const node = this.caretPositionFromIndex(index)?.offsetNode;
|
|
230
229
|
return node?.type === 'text' ? node.parentNode : node;
|
|
231
230
|
}
|
|
@@ -238,12 +237,11 @@ let AstElement = (() => {
|
|
|
238
237
|
* @param y line number / 行数
|
|
239
238
|
*/
|
|
240
239
|
elementFromPoint(x, y) {
|
|
241
|
-
// eslint-disable-next-line no-unused-labels
|
|
242
240
|
LSP: return this.elementFromIndex(this.indexFromPos(y, x));
|
|
243
241
|
}
|
|
244
242
|
/** @private */
|
|
245
243
|
lint(start = this.getAbsoluteIndex(), re) {
|
|
246
|
-
LINT: {
|
|
244
|
+
LINT: {
|
|
247
245
|
const errors = [];
|
|
248
246
|
for (let i = 0, cur = start + this.getAttribute('padding'); i < this.length; i++) {
|
|
249
247
|
const child = this.childNodes[i];
|
package/dist/lib/lintConfig.js
CHANGED
package/dist/lib/lsp.d.ts
CHANGED
|
@@ -157,7 +157,6 @@ export declare class LanguageService implements LanguageServiceBase {
|
|
|
157
157
|
* @param wiki Wikipedia URL / 维基百科网址
|
|
158
158
|
* @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
|
|
159
159
|
* @since v1.18.1
|
|
160
|
-
* @throws `RangeError` 不是有效的维基百科网址
|
|
161
160
|
*/
|
|
162
161
|
setTargetWikipedia(wiki: string, user: string): Promise<void>;
|
|
163
162
|
}
|
package/dist/lib/lsp.js
CHANGED
|
@@ -498,7 +498,6 @@ class LanguageService {
|
|
|
498
498
|
* 颜色选择器
|
|
499
499
|
* @param color color information / 颜色信息
|
|
500
500
|
*/
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
502
501
|
provideColorPresentations(color) {
|
|
503
502
|
const { color: { red, green, blue, alpha }, range } = color, rgb = [red, green, blue], newText = alpha < 1
|
|
504
503
|
? `rgba(${rgb.map(c => Math.round(c * 255)).join()},${alpha})`
|
|
@@ -789,7 +788,7 @@ class LanguageService {
|
|
|
789
788
|
/* eslint-disable @stylistic/operator-linebreak */
|
|
790
789
|
cssDiagnostics = await document_1.stylelint ?
|
|
791
790
|
await (async () => {
|
|
792
|
-
NPM: {
|
|
791
|
+
NPM: {
|
|
793
792
|
const tokens = this.findStyleTokens();
|
|
794
793
|
if (tokens.length === 0) {
|
|
795
794
|
return [];
|
|
@@ -999,7 +998,7 @@ class LanguageService {
|
|
|
999
998
|
let name;
|
|
1000
999
|
if (token.is('magic-word')) {
|
|
1001
1000
|
({ name } = token);
|
|
1002
|
-
token = token.childNodes[1].lastChild;
|
|
1001
|
+
token = token.childNodes[1].lastChild;
|
|
1003
1002
|
}
|
|
1004
1003
|
else if (token.is('image-parameter')) {
|
|
1005
1004
|
({ name } = token);
|
|
@@ -1417,7 +1416,6 @@ class LanguageService {
|
|
|
1417
1416
|
* 提供快速修复建议
|
|
1418
1417
|
* @param diagnostics grammar diagnostics / 语法诊断信息
|
|
1419
1418
|
*/
|
|
1420
|
-
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
1421
1419
|
provideCodeAction(diagnostics) {
|
|
1422
1420
|
const actionable = diagnostics.filter((diagnostic) => diagnostic.data), fixable = actionable.filter(({ source, data }) => source === 'WikiLint' && data.some(({ fix }) => fix)), fixableRules = [...new Set(fixable.map(({ code }) => code))];
|
|
1423
1421
|
return [
|
|
@@ -1498,7 +1496,6 @@ class LanguageService {
|
|
|
1498
1496
|
* @param wiki Wikipedia URL / 维基百科网址
|
|
1499
1497
|
* @param user URI for wiki userpage or email address of the user / 维基用户页面地址或用户的电子邮件地址
|
|
1500
1498
|
* @since v1.18.1
|
|
1501
|
-
* @throws `RangeError` 不是有效的维基百科网址
|
|
1502
1499
|
*/
|
|
1503
1500
|
async setTargetWikipedia(wiki, user) {
|
|
1504
1501
|
const [site, host] = index_1.default.getWMFSite(wiki);
|
package/dist/lib/node.js
CHANGED
|
@@ -112,7 +112,7 @@ let AstNode = (() => {
|
|
|
112
112
|
this.#previousSibling = value;
|
|
113
113
|
break;
|
|
114
114
|
case 'aIndex':
|
|
115
|
-
LINT: {
|
|
115
|
+
LINT: {
|
|
116
116
|
this.#aIndex = [debug_1.Shadow.rev, value];
|
|
117
117
|
}
|
|
118
118
|
break;
|
|
@@ -141,7 +141,7 @@ let AstNode = (() => {
|
|
|
141
141
|
* @param left column number / 列号
|
|
142
142
|
*/
|
|
143
143
|
indexFromPos(top, left) {
|
|
144
|
-
LSP: {
|
|
144
|
+
LSP: {
|
|
145
145
|
if (top < 0 || left < 0) {
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
@@ -160,7 +160,7 @@ let AstNode = (() => {
|
|
|
160
160
|
* @param index character index / 字符位置
|
|
161
161
|
*/
|
|
162
162
|
posFromIndex(index) {
|
|
163
|
-
LINT: {
|
|
163
|
+
LINT: {
|
|
164
164
|
const { length } = String(this);
|
|
165
165
|
index += index < 0 ? length : 0;
|
|
166
166
|
if (index >= 0 && index <= length) {
|
|
@@ -172,7 +172,7 @@ let AstNode = (() => {
|
|
|
172
172
|
}
|
|
173
173
|
/** @private */
|
|
174
174
|
getDimension() {
|
|
175
|
-
LINT: {
|
|
175
|
+
LINT: {
|
|
176
176
|
const lines = this.getLines(), last = lines[lines.length - 1];
|
|
177
177
|
return { height: lines.length, width: last[2] - last[1] };
|
|
178
178
|
}
|
|
@@ -213,8 +213,7 @@ let AstNode = (() => {
|
|
|
213
213
|
*/
|
|
214
214
|
getAbsoluteIndex() {
|
|
215
215
|
// 也用于Prism-Wiki
|
|
216
|
-
return (0, lint_1.cache)(
|
|
217
|
-
this.#aIndex, () => {
|
|
216
|
+
return (0, lint_1.cache)(this.#aIndex, () => {
|
|
218
217
|
const { parentNode } = this;
|
|
219
218
|
return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
|
|
220
219
|
}, value => {
|
|
@@ -227,7 +226,6 @@ let AstNode = (() => {
|
|
|
227
226
|
* 获取当前节点的行列位置和大小
|
|
228
227
|
*/
|
|
229
228
|
getBoundingClientRect() {
|
|
230
|
-
// eslint-disable-next-line no-unused-labels
|
|
231
229
|
LSP: return {
|
|
232
230
|
...this.getDimension(),
|
|
233
231
|
...this.getRootNode().posFromIndex(this.getAbsoluteIndex()),
|
|
@@ -250,7 +248,7 @@ let AstNode = (() => {
|
|
|
250
248
|
* @since v1.16.3
|
|
251
249
|
*/
|
|
252
250
|
getLines() {
|
|
253
|
-
LINT: {
|
|
251
|
+
LINT: {
|
|
254
252
|
const results = [];
|
|
255
253
|
let start = 0;
|
|
256
254
|
for (const line of String(this).split('\n')) {
|
package/dist/lib/text.js
CHANGED
|
@@ -9,7 +9,7 @@ const lint_1 = require("../util/lint");
|
|
|
9
9
|
const debug_1 = require("../util/debug");
|
|
10
10
|
const index_1 = __importDefault(require("../index"));
|
|
11
11
|
const node_1 = require("./node");
|
|
12
|
-
const sp = /* #__PURE__ */ (() => String.raw `[${string_1.zs}\t]*`)(),
|
|
12
|
+
const sp = /* #__PURE__ */ (() => String.raw `[${string_1.zs}\t]*`)(), source = /* #__PURE__ */ (() => String.raw `<(?:/[^\S\n]*)?([a-z]\w*)|\{+|\}+|\[{2,}|\[(?![^[]*?\])|((?:^|\])[^[]*?)\]+|\n={2,}`)();
|
|
13
13
|
const errorSyntax = /* #__PURE__ */ (() => new RegExp(String.raw `${source}|https?[:/]/+|(?:rfc|pmid)(?=[-::]?${sp}\d)|isbn(?=[-::]?${sp}(?:\d(?:${sp}|-)){6})`, 'giu'))();
|
|
14
14
|
const errorSyntaxUrl = /* #__PURE__ */ new RegExp(source, 'giu'), noLinkTypes = new Set(['attr-value', 'ext-link-text', 'link-text']), regexes = {
|
|
15
15
|
'[': /[[\]]/u,
|
|
@@ -77,7 +77,7 @@ class AstText extends node_1.AstNode {
|
|
|
77
77
|
}
|
|
78
78
|
/** @private */
|
|
79
79
|
lint(start = this.getAbsoluteIndex(), errorRegex) {
|
|
80
|
-
LINT: {
|
|
80
|
+
LINT: {
|
|
81
81
|
if (errorRegex === false) {
|
|
82
82
|
return [];
|
|
83
83
|
}
|
|
@@ -121,6 +121,10 @@ class AstText extends node_1.AstNode {
|
|
|
121
121
|
index += length;
|
|
122
122
|
error = error.slice(length);
|
|
123
123
|
}
|
|
124
|
+
else if (error.startsWith('\n==')) {
|
|
125
|
+
index++;
|
|
126
|
+
error = error.slice(1);
|
|
127
|
+
}
|
|
124
128
|
error = error.toLowerCase();
|
|
125
129
|
const [char] = error, magicLink = char === 'r' || char === 'p' || char === 'i', lbrace = char === '{', rbrace = char === '}', lbrack = char === '[', rbrack = char === ']';
|
|
126
130
|
let { length } = error;
|
|
@@ -134,7 +138,7 @@ class AstText extends node_1.AstNode {
|
|
|
134
138
|
errorRegex.lastIndex--;
|
|
135
139
|
}
|
|
136
140
|
// Rule & Severity
|
|
137
|
-
let startIndex = start + index, endIndex = startIndex + length, rule, severity;
|
|
141
|
+
let startIndex = start + index, endIndex = startIndex + length, rule, severity, endLine, endCol;
|
|
138
142
|
const nextChar = rootStr[endIndex], previousChar = rootStr[startIndex - 1], leftBracket = lbrace || lbrack, lConverter = lbrace && previousChar === '-' && variants.length > 0, rConverter = rbrace && nextChar === '-' && variants.length > 0, brokenExtLink = lbrack && nextType === 'free-ext-link' && !data.slice(index + 1).trim()
|
|
139
143
|
|| rbrack && previousType === 'free-ext-link'
|
|
140
144
|
&& !data.slice(0, index).includes(']');
|
|
@@ -157,6 +161,10 @@ class AstText extends node_1.AstNode {
|
|
|
157
161
|
}
|
|
158
162
|
severity = lintConfig.getSeverity(rule, key);
|
|
159
163
|
}
|
|
164
|
+
else if (char === '=') {
|
|
165
|
+
rule = 'syntax-like';
|
|
166
|
+
severity = lintConfig.getSeverity(rule, 'heading');
|
|
167
|
+
}
|
|
160
168
|
else if (lConverter || rConverter) {
|
|
161
169
|
rule = 'lonely-bracket';
|
|
162
170
|
severity = lintConfig.getSeverity(rule, 'converter');
|
|
@@ -210,16 +218,51 @@ class AstText extends node_1.AstNode {
|
|
|
210
218
|
continue;
|
|
211
219
|
}
|
|
212
220
|
// LintError
|
|
213
|
-
const pos = this.posFromIndex(index), { line: startLine, character: startCol } = (0, lint_1.getEndPos)(top, left, pos.top + 1, pos.left)
|
|
221
|
+
const pos = this.posFromIndex(index), { line: startLine, character: startCol } = (0, lint_1.getEndPos)(top, left, pos.top + 1, pos.left);
|
|
222
|
+
if (char === '=') {
|
|
223
|
+
const lineEnd = data.indexOf('\n', index);
|
|
224
|
+
let sibling = nextSibling, line;
|
|
225
|
+
if (lineEnd === -1) {
|
|
226
|
+
let end = 0;
|
|
227
|
+
while (sibling) {
|
|
228
|
+
if (sibling.type === 'text') {
|
|
229
|
+
end = sibling.data.indexOf('\n');
|
|
230
|
+
if (end !== -1) {
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
sibling = sibling.nextSibling;
|
|
235
|
+
}
|
|
236
|
+
if (!sibling) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
line = sibling.data.slice(0, end);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
line = data.slice(index + length, lineEnd);
|
|
243
|
+
}
|
|
244
|
+
if (!/(?:^|[^=])=+\s*(?:\S\s*)?$/u.test(line)) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (lineEnd === -1) {
|
|
248
|
+
endIndex = sibling.getAbsoluteIndex() + line.length;
|
|
249
|
+
({ top: endLine, left: endCol } = root.posFromIndex(endIndex));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
endIndex += line.length;
|
|
253
|
+
length += line.length;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const e = {
|
|
214
257
|
rule,
|
|
215
|
-
message: index_1.default.msg('lonely', magicLink || char === 'h' || lConverter || rConverter ? error : char),
|
|
258
|
+
message: index_1.default.msg(char === '=' ? 'header-like' : 'lonely', magicLink || char === 'h' || lConverter || rConverter ? error : char),
|
|
216
259
|
severity,
|
|
217
260
|
startIndex,
|
|
218
261
|
endIndex,
|
|
219
262
|
startLine,
|
|
220
|
-
endLine: startLine,
|
|
263
|
+
endLine: endLine ?? startLine,
|
|
221
264
|
startCol,
|
|
222
|
-
endCol: startCol + length,
|
|
265
|
+
endCol: endCol ?? startCol + length,
|
|
223
266
|
};
|
|
224
267
|
// Suggestions
|
|
225
268
|
if (lintConfig.computeEditInfo) {
|
|
@@ -278,7 +321,7 @@ class AstText extends node_1.AstNode {
|
|
|
278
321
|
* @throws `Error` 没有父节点
|
|
279
322
|
*/
|
|
280
323
|
splitText(offset) {
|
|
281
|
-
LSP: {
|
|
324
|
+
LSP: {
|
|
282
325
|
const { parentNode, data } = this;
|
|
283
326
|
/* istanbul ignore if */
|
|
284
327
|
if (!parentNode) {
|
|
@@ -298,7 +341,7 @@ class AstText extends node_1.AstNode {
|
|
|
298
341
|
* @throws `Error` 没有父节点
|
|
299
342
|
*/
|
|
300
343
|
escape() {
|
|
301
|
-
LSP: {
|
|
344
|
+
LSP: {
|
|
302
345
|
const { parentNode } = this;
|
|
303
346
|
/* istanbul ignore if */
|
|
304
347
|
if (!parentNode) {
|
package/dist/lib/title.js
CHANGED
|
@@ -7,21 +7,19 @@ const debug_1 = require("../util/debug");
|
|
|
7
7
|
* @param i AttributesToken子节点的位置
|
|
8
8
|
*/
|
|
9
9
|
const attributesParent = (i = 0) => (constructor) => {
|
|
10
|
-
LINT: {
|
|
11
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
10
|
+
LINT: {
|
|
12
11
|
class AttributesParent extends constructor {
|
|
13
12
|
/** AttributesToken子节点 */
|
|
14
13
|
#getAttributesChild() {
|
|
15
14
|
return this.childNodes[i];
|
|
16
15
|
}
|
|
17
16
|
hasAttr(key) {
|
|
18
|
-
LSP: return this.#getAttributesChild().hasAttr(key);
|
|
17
|
+
LSP: return this.#getAttributesChild().hasAttr(key);
|
|
19
18
|
}
|
|
20
19
|
getAttr(key) {
|
|
21
20
|
return this.#getAttributesChild().getAttr(key);
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
25
23
|
(0, debug_1.mixin)(AttributesParent, constructor);
|
|
26
24
|
return AttributesParent;
|
|
27
25
|
}
|
|
@@ -5,8 +5,7 @@ const debug_1 = require("../util/debug");
|
|
|
5
5
|
const selector_1 = require("../parser/selector");
|
|
6
6
|
/** @ignore */
|
|
7
7
|
const elementLike = (constructor) => {
|
|
8
|
-
LINT: {
|
|
9
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
8
|
+
LINT: {
|
|
10
9
|
class ElementLike extends constructor {
|
|
11
10
|
#getCondition(selector) {
|
|
12
11
|
return (0, selector_1.getCondition)(selector,
|
|
@@ -52,14 +51,13 @@ const elementLike = (constructor) => {
|
|
|
52
51
|
return this.getElementsBy(this.#getCondition(selector));
|
|
53
52
|
}
|
|
54
53
|
escape() {
|
|
55
|
-
LSP: {
|
|
54
|
+
LSP: {
|
|
56
55
|
for (const child of this.childNodes) {
|
|
57
56
|
child.escape();
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
63
61
|
(0, debug_1.mixin)(ElementLike, constructor);
|
|
64
62
|
return ElementLike;
|
|
65
63
|
}
|
package/dist/mixin/gapped.js
CHANGED
|
@@ -7,13 +7,11 @@ const debug_1 = require("../util/debug");
|
|
|
7
7
|
* @param gap
|
|
8
8
|
*/
|
|
9
9
|
const gapped = (gap = 1) => (constructor) => {
|
|
10
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
11
10
|
class GappedToken extends constructor {
|
|
12
11
|
getGaps() {
|
|
13
12
|
return gap;
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
17
15
|
(0, debug_1.mixin)(GappedToken, constructor);
|
|
18
16
|
return GappedToken;
|
|
19
17
|
};
|
package/dist/mixin/hidden.js
CHANGED
|
@@ -8,17 +8,15 @@ const debug_1 = require("../util/debug");
|
|
|
8
8
|
* @param html 是否覆写 toHtml 方法
|
|
9
9
|
*/
|
|
10
10
|
const hiddenToken = (linter = true, html = true) => (constructor) => {
|
|
11
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
12
11
|
class AnyHiddenToken extends constructor {
|
|
13
12
|
text() {
|
|
14
13
|
return '';
|
|
15
14
|
}
|
|
16
15
|
lint(start) {
|
|
17
16
|
// @ts-expect-error private argument
|
|
18
|
-
LINT: return linter ? [] : super.lint(start);
|
|
17
|
+
LINT: return linter ? [] : super.lint(start);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
22
20
|
(0, debug_1.mixin)(AnyHiddenToken, constructor);
|
|
23
21
|
return AnyHiddenToken;
|
|
24
22
|
};
|
package/dist/mixin/noEscape.js
CHANGED
|
@@ -7,14 +7,12 @@ const debug_1 = require("../util/debug");
|
|
|
7
7
|
* @ignore
|
|
8
8
|
*/
|
|
9
9
|
const noEscape = (constructor) => {
|
|
10
|
-
LSP: {
|
|
11
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
10
|
+
LSP: {
|
|
12
11
|
class NoEscapeToken extends constructor {
|
|
13
12
|
escape() {
|
|
14
13
|
//
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
18
16
|
(0, debug_1.mixin)(NoEscapeToken, constructor);
|
|
19
17
|
return NoEscapeToken;
|
|
20
18
|
}
|
package/dist/mixin/nodeLike.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.nodeLike = void 0;
|
|
|
4
4
|
const debug_1 = require("../util/debug");
|
|
5
5
|
/** @ignore */
|
|
6
6
|
const nodeLike = (constructor) => {
|
|
7
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
8
7
|
class NodeLike extends constructor {
|
|
9
8
|
get firstChild() {
|
|
10
9
|
return this.childNodes[0];
|
|
@@ -13,13 +12,12 @@ const nodeLike = (constructor) => {
|
|
|
13
12
|
return this.childNodes[this.childNodes.length - 1];
|
|
14
13
|
}
|
|
15
14
|
get offsetHeight() {
|
|
16
|
-
LINT: return this.getDimension().height;
|
|
15
|
+
LINT: return this.getDimension().height;
|
|
17
16
|
}
|
|
18
17
|
get offsetWidth() {
|
|
19
|
-
LINT: return this.getDimension().width;
|
|
18
|
+
LINT: return this.getDimension().width;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
23
21
|
(0, debug_1.mixin)(NodeLike, constructor);
|
|
24
22
|
return NodeLike;
|
|
25
23
|
};
|
package/dist/mixin/padded.js
CHANGED
|
@@ -8,16 +8,12 @@ const debug_1 = require("../util/debug");
|
|
|
8
8
|
* @param padding.length
|
|
9
9
|
*/
|
|
10
10
|
const padded = ({ length }) => (constructor) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getAttribute(key) {
|
|
15
|
-
return key === 'padding' ? length : super.getAttribute(key);
|
|
16
|
-
}
|
|
11
|
+
class PaddedToken extends constructor {
|
|
12
|
+
getAttribute(key) {
|
|
13
|
+
return key === 'padding' ? length : super.getAttribute(key);
|
|
17
14
|
}
|
|
18
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
|
19
|
-
(0, debug_1.mixin)(PaddedToken, constructor);
|
|
20
|
-
return PaddedToken;
|
|
21
15
|
}
|
|
16
|
+
(0, debug_1.mixin)(PaddedToken, constructor);
|
|
17
|
+
return PaddedToken;
|
|
22
18
|
};
|
|
23
19
|
exports.padded = padded;
|
|
@@ -68,7 +68,7 @@ const parseCommentAndExt = (wikitext, config, accum, includeOnly) => {
|
|
|
68
68
|
wikitext = wikitext.replace(/<nowiki>[\s\S]*?<\/nowiki>/giu, m => {
|
|
69
69
|
stack.push(m);
|
|
70
70
|
return `\0${stack.length - 1}\x7F`;
|
|
71
|
-
}).replace(/<translate( nowrap)?>([\s\S]
|
|
71
|
+
}).replace(/<translate( nowrap)?>([\s\S]*?)<\/translate>/gu, (_, p1, p2) => {
|
|
72
72
|
const l = accum.length;
|
|
73
73
|
// @ts-expect-error abstract class
|
|
74
74
|
new translate_1.TranslateToken(p1, p2 && (0, string_1.restore)(p2, stack), newConfig, accum);
|