wikiparser-node 1.1.2 → 1.1.3
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/src/heading.js +5 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +8 -2
- package/package.json +1 -1
package/dist/src/heading.js
CHANGED
|
@@ -80,19 +80,19 @@ class HeadingToken extends (0, sol_1.sol)((0, fixed_1.fixed)(index_1.Token)) {
|
|
|
80
80
|
}
|
|
81
81
|
/** @override */
|
|
82
82
|
lint(start = this.getAbsoluteIndex()) {
|
|
83
|
-
const errors = super.lint(start), innerStr = String(
|
|
83
|
+
const errors = super.lint(start), { firstChild } = this, innerStr = String(firstChild);
|
|
84
|
+
const equals = this.#equals, excerpt = `${equals}${innerStr}${equals}`.slice(0, 50);
|
|
84
85
|
let refError;
|
|
85
86
|
if (this.level === 1) {
|
|
86
|
-
refError = (0, lint_1.
|
|
87
|
+
refError = { ...(0, lint_1.generateForChild)(firstChild, { start }, '<h1>'), excerpt };
|
|
87
88
|
errors.push(refError);
|
|
88
89
|
}
|
|
89
90
|
if (innerStr.startsWith('=') || innerStr.endsWith('=')) {
|
|
90
|
-
refError ??= (0, lint_1.
|
|
91
|
+
refError ??= { ...(0, lint_1.generateForChild)(firstChild, { start }, ''), excerpt };
|
|
91
92
|
errors.push({ ...refError, message: Parser.msg('unbalanced "=" in a section header') });
|
|
92
93
|
}
|
|
93
94
|
if (this.closest('html-attrs, table-attrs')) {
|
|
94
|
-
|
|
95
|
-
errors.push({ ...refError, message: Parser.msg('section header in a HTML tag') });
|
|
95
|
+
errors.push({ ...(0, lint_1.generateForSelf)(this, { start }, ''), message: Parser.msg('section header in a HTML tag') });
|
|
96
96
|
}
|
|
97
97
|
return errors;
|
|
98
98
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ export declare class Token extends AstElement {
|
|
|
132
132
|
* @param tag HTML标签名
|
|
133
133
|
* @throws `RangeError` 非法的标签或空标签
|
|
134
134
|
*/
|
|
135
|
-
findEnclosingHtml(tag?: string):
|
|
135
|
+
findEnclosingHtml(tag?: string): AstRange | undefined;
|
|
136
136
|
/** 获取全部分类 */
|
|
137
137
|
getCategories(): [string, string | undefined][];
|
|
138
138
|
/** 重新解析单引号 */
|
package/dist/src/index.js
CHANGED
|
@@ -599,7 +599,7 @@ class Token extends element_1.AstElement {
|
|
|
599
599
|
}
|
|
600
600
|
const { childNodes } = this, headings = [...childNodes.entries()]
|
|
601
601
|
.filter(([, { type }]) => type === 'heading')
|
|
602
|
-
.map(([i, {
|
|
602
|
+
.map(([i, { level }]) => [i, level]), lastHeading = [-1, -1, -1, -1, -1, -1], sections = new Array(headings.length);
|
|
603
603
|
for (let i = 0; i < headings.length; i++) {
|
|
604
604
|
const [index, level] = headings[i];
|
|
605
605
|
for (let j = level; j < 6; j++) {
|
|
@@ -657,7 +657,13 @@ class Token extends element_1.AstElement {
|
|
|
657
657
|
break;
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
-
|
|
660
|
+
if (i === length) {
|
|
661
|
+
return parentNode.findEnclosingHtml(tag);
|
|
662
|
+
}
|
|
663
|
+
const range = this.createRange();
|
|
664
|
+
range.setStartBefore(opening);
|
|
665
|
+
range.setEnd(parentNode, i + 1);
|
|
666
|
+
return range;
|
|
661
667
|
}
|
|
662
668
|
/** 获取全部分类 */
|
|
663
669
|
getCategories() {
|