@markuplint/parser-utils 3.3.0 → 3.4.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/lib/const.d.ts +1 -1
- package/lib/create-token.d.ts +6 -1
- package/lib/detect-element-type.d.ts +5 -1
- package/lib/detect-element-type.js +1 -1
- package/lib/get-location.d.ts +12 -8
- package/lib/get-location.js +2 -1
- package/lib/idl-attributes.d.ts +2 -2
- package/lib/idl-attributes.js +3 -4
- package/lib/parser-error.d.ts +19 -11
- package/lib/siblings-correction.js +3 -0
- package/lib/types.d.ts +12 -12
- package/package.json +3 -3
package/lib/const.d.ts
CHANGED
package/lib/create-token.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { MLToken } from '@markuplint/ml-ast';
|
|
2
|
-
export declare function tokenizer(
|
|
2
|
+
export declare function tokenizer(
|
|
3
|
+
raw: string | null,
|
|
4
|
+
startLine: number,
|
|
5
|
+
startCol: number,
|
|
6
|
+
startOffset: number,
|
|
7
|
+
): MLToken;
|
|
3
8
|
export declare function createTokenFromRawCode(raw: string | null, startOffset: number, rawCode: string): MLToken;
|
|
4
9
|
export declare function uuid(): string;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { ElementType, ParserAuthoredElementNameDistinguishing } from '@markuplint/ml-ast';
|
|
2
|
-
export declare function detectElementType(
|
|
2
|
+
export declare function detectElementType(
|
|
3
|
+
name: string,
|
|
4
|
+
option?: ParserAuthoredElementNameDistinguishing,
|
|
5
|
+
defaultPattern?: ParserAuthoredElementNameDistinguishing,
|
|
6
|
+
): ElementType;
|
|
@@ -30,7 +30,7 @@ function _distinguishAuthoredName(name, patterns) {
|
|
|
30
30
|
}
|
|
31
31
|
function toRegexp(pattern) {
|
|
32
32
|
const matched = pattern.match(/^\/(.+)\/([ig]*)$/i);
|
|
33
|
-
if (matched) {
|
|
33
|
+
if (matched && matched[1]) {
|
|
34
34
|
return new RegExp(matched[1], matched[2]);
|
|
35
35
|
}
|
|
36
36
|
return new RegExp(pattern);
|
package/lib/get-location.d.ts
CHANGED
|
@@ -2,12 +2,16 @@ export declare function getLine(html: string, startOffset: number): number;
|
|
|
2
2
|
export declare function getCol(html: string, startOffset: number): number;
|
|
3
3
|
export declare function getEndLine(html: string, line: number): number;
|
|
4
4
|
export declare function getEndCol(html: string, col: number): number;
|
|
5
|
-
export declare function sliceFragment(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
export declare function sliceFragment(
|
|
6
|
+
rawHtml: string,
|
|
7
|
+
start: number,
|
|
8
|
+
end: number,
|
|
9
|
+
): {
|
|
10
|
+
startOffset: number;
|
|
11
|
+
endOffset: number;
|
|
12
|
+
startLine: number;
|
|
13
|
+
endLine: number;
|
|
14
|
+
startCol: number;
|
|
15
|
+
endCol: number;
|
|
16
|
+
raw: string;
|
|
13
17
|
};
|
package/lib/get-location.js
CHANGED
|
@@ -6,8 +6,9 @@ function getLine(html, startOffset) {
|
|
|
6
6
|
}
|
|
7
7
|
exports.getLine = getLine;
|
|
8
8
|
function getCol(html, startOffset) {
|
|
9
|
+
var _a;
|
|
9
10
|
const lines = html.slice(0, startOffset).split(/\n/g);
|
|
10
|
-
return lines[lines.length - 1].length + 1;
|
|
11
|
+
return ((_a = lines[lines.length - 1]) !== null && _a !== void 0 ? _a : '').length + 1;
|
|
11
12
|
}
|
|
12
13
|
exports.getCol = getCol;
|
|
13
14
|
function getEndLine(html, line) {
|
package/lib/idl-attributes.d.ts
CHANGED
package/lib/idl-attributes.js
CHANGED
|
@@ -109,9 +109,8 @@ const idlContentMap = {
|
|
|
109
109
|
placeholder: 'placeholder',
|
|
110
110
|
playsInline: 'playsinline',
|
|
111
111
|
popover: 'popover',
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
popoverToggleTarget: 'popovertoggletarget',
|
|
112
|
+
popoverTarget: 'popovertarget',
|
|
113
|
+
popoverTargetAction: 'popovertargetaction',
|
|
115
114
|
poster: 'poster',
|
|
116
115
|
preload: 'preload',
|
|
117
116
|
profile: 'profile',
|
|
@@ -433,7 +432,7 @@ function searchIDLAttribute(name) {
|
|
|
433
432
|
}
|
|
434
433
|
exports.searchIDLAttribute = searchIDLAttribute;
|
|
435
434
|
function camelize(str) {
|
|
436
|
-
return str.replace(/[:-][a-z]/g, $0 => $0[1].toUpperCase());
|
|
435
|
+
return str.replace(/[:-][a-z]/g, $0 => { var _a, _b; return (_b = (_a = $0[1]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : ''; });
|
|
437
436
|
}
|
|
438
437
|
function hyphenize(str) {
|
|
439
438
|
return str.replace(/[A-Z]/g, $0 => `-${$0.toLowerCase()}`);
|
package/lib/parser-error.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
export declare class ParserError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
readonly col: number;
|
|
3
|
+
readonly line: number;
|
|
4
|
+
name: string;
|
|
5
|
+
readonly nodeName: string | null;
|
|
6
|
+
readonly raw: string;
|
|
7
|
+
constructor(
|
|
8
|
+
message: string,
|
|
9
|
+
{
|
|
10
|
+
line,
|
|
11
|
+
col,
|
|
12
|
+
raw,
|
|
13
|
+
nodeName,
|
|
14
|
+
}: {
|
|
15
|
+
line?: number;
|
|
16
|
+
col?: number;
|
|
17
|
+
raw?: string;
|
|
18
|
+
nodeName?: string | null;
|
|
19
|
+
},
|
|
20
|
+
);
|
|
13
21
|
}
|
|
@@ -12,6 +12,9 @@ function siblingsCorrection(nodeList) {
|
|
|
12
12
|
for (let i = 0; i < nodeList.length; i++) {
|
|
13
13
|
const prevNode = nodeList[i - 1] || null;
|
|
14
14
|
const node = nodeList[i];
|
|
15
|
+
if (!node) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
15
18
|
const nextNode = nodeList[i + 1] || null;
|
|
16
19
|
node.prevNode = prevNode;
|
|
17
20
|
node.nextNode = nextNode;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export type Code = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
type: string;
|
|
3
|
+
index: number;
|
|
4
|
+
startTag: string;
|
|
5
|
+
taggedCode: string;
|
|
6
|
+
endTag: string | null;
|
|
7
7
|
};
|
|
8
8
|
export type IgnoreTag = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
type: string;
|
|
10
|
+
start: RegExp;
|
|
11
|
+
end: RegExp;
|
|
12
12
|
};
|
|
13
13
|
export type IgnoreBlock = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
source: string;
|
|
15
|
+
replaced: string;
|
|
16
|
+
stack: Code[];
|
|
17
|
+
maskChar: string;
|
|
18
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/parser-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Utility module for markuplint parser plugin",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@markuplint/ml-ast": "3.0.0",
|
|
26
|
-
"@markuplint/types": "3.
|
|
26
|
+
"@markuplint/types": "3.3.0",
|
|
27
27
|
"tslib": "^2.4.1",
|
|
28
28
|
"uuid": "^9.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@markuplint/ml-core": "3.x"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
|
|
34
34
|
}
|