@markuplint/parser-utils 3.2.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 +4 -1
- 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 +7 -4
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
|
@@ -108,6 +108,9 @@ const idlContentMap = {
|
|
|
108
108
|
pattern: 'pattern',
|
|
109
109
|
placeholder: 'placeholder',
|
|
110
110
|
playsInline: 'playsinline',
|
|
111
|
+
popover: 'popover',
|
|
112
|
+
popoverTarget: 'popovertarget',
|
|
113
|
+
popoverTargetAction: 'popovertargetaction',
|
|
111
114
|
poster: 'poster',
|
|
112
115
|
preload: 'preload',
|
|
113
116
|
profile: 'profile',
|
|
@@ -429,7 +432,7 @@ function searchIDLAttribute(name) {
|
|
|
429
432
|
}
|
|
430
433
|
exports.searchIDLAttribute = searchIDLAttribute;
|
|
431
434
|
function camelize(str) {
|
|
432
|
-
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 : ''; });
|
|
433
436
|
}
|
|
434
437
|
function hyphenize(str) {
|
|
435
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>",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
+
"typedoc": {
|
|
15
|
+
"entryPoint": "./src/index.ts"
|
|
16
|
+
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"build": "tsc",
|
|
16
19
|
"clean": "tsc --build --clean"
|
|
@@ -19,13 +22,13 @@
|
|
|
19
22
|
"@types/uuid": "^9.0.0"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"@markuplint/ml-ast": "3.0.0
|
|
23
|
-
"@markuplint/types": "3.
|
|
25
|
+
"@markuplint/ml-ast": "3.0.0",
|
|
26
|
+
"@markuplint/types": "3.3.0",
|
|
24
27
|
"tslib": "^2.4.1",
|
|
25
28
|
"uuid": "^9.0.0"
|
|
26
29
|
},
|
|
27
30
|
"peerDependencies": {
|
|
28
31
|
"@markuplint/ml-core": "3.x"
|
|
29
32
|
},
|
|
30
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
|
|
31
34
|
}
|