@markuplint/parser-utils 3.8.0 → 3.10.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 +1 -6
- package/lib/detect-element-type.d.ts +1 -5
- package/lib/get-location.d.ts +8 -12
- package/lib/get-space-before.d.ts +1 -1
- package/lib/idl-attributes.d.ts +2 -2
- package/lib/parse-attr.d.ts +15 -18
- package/lib/parser-error.d.ts +24 -19
- package/lib/parser-error.js +30 -7
- package/lib/tag-splitter.d.ts +4 -4
- package/lib/types.d.ts +12 -12
- package/package.json +7 -10
package/lib/const.d.ts
CHANGED
package/lib/create-token.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { MLToken } from '@markuplint/ml-ast';
|
|
2
|
-
export declare function tokenizer(
|
|
3
|
-
raw: string | null,
|
|
4
|
-
startLine: number,
|
|
5
|
-
startCol: number,
|
|
6
|
-
startOffset: number,
|
|
7
|
-
): MLToken;
|
|
2
|
+
export declare function tokenizer(raw: string | null, startLine: number, startCol: number, startOffset: number): MLToken;
|
|
8
3
|
export declare function createTokenFromRawCode(raw: string | null, startOffset: number, rawCode: string): MLToken;
|
|
9
4
|
export declare function uuid(): string;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import type { ElementType, ParserAuthoredElementNameDistinguishing } from '@markuplint/ml-ast';
|
|
2
|
-
export declare function detectElementType(
|
|
3
|
-
name: string,
|
|
4
|
-
option?: ParserAuthoredElementNameDistinguishing,
|
|
5
|
-
defaultPattern?: ParserAuthoredElementNameDistinguishing,
|
|
6
|
-
): ElementType;
|
|
2
|
+
export declare function detectElementType(name: string, option?: ParserAuthoredElementNameDistinguishing, defaultPattern?: ParserAuthoredElementNameDistinguishing): ElementType;
|
package/lib/get-location.d.ts
CHANGED
|
@@ -2,16 +2,12 @@ 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
|
-
|
|
13
|
-
endLine: number;
|
|
14
|
-
startCol: number;
|
|
15
|
-
endCol: number;
|
|
16
|
-
raw: string;
|
|
5
|
+
export declare function sliceFragment(rawHtml: string, start: number, end: number): {
|
|
6
|
+
startOffset: number;
|
|
7
|
+
endOffset: number;
|
|
8
|
+
startLine: number;
|
|
9
|
+
endLine: number;
|
|
10
|
+
startCol: number;
|
|
11
|
+
endCol: number;
|
|
12
|
+
raw: string;
|
|
17
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getSpaceBefore(offset: number, rawCode: string): import(
|
|
1
|
+
export declare function getSpaceBefore(offset: number, rawCode: string): import("@markuplint/ml-ast").MLToken;
|
package/lib/idl-attributes.d.ts
CHANGED
package/lib/parse-attr.d.ts
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import type { MLASTHTMLAttr } from '@markuplint/ml-ast';
|
|
2
2
|
type ParseAttrOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
readonly booleanish?: boolean;
|
|
4
|
+
readonly valueDelimiters?: readonly ValueDelimiter[];
|
|
5
|
+
readonly equal?: string;
|
|
6
6
|
};
|
|
7
7
|
type ValueDelimiter = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
readonly start: string;
|
|
9
|
+
readonly end: string;
|
|
10
10
|
};
|
|
11
11
|
export declare const defaultValueDelimiters: readonly ValueDelimiter[];
|
|
12
12
|
export declare function parseAttr(raw: string, offset: number, html: string, options?: ParseAttrOptions): MLASTHTMLAttr;
|
|
13
|
-
export declare function tokenize(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
value: string;
|
|
24
|
-
endQuote: string;
|
|
25
|
-
afterAttr: string;
|
|
13
|
+
export declare function tokenize(raw: string, options?: ParseAttrOptions): {
|
|
14
|
+
beforeName: string;
|
|
15
|
+
name: string;
|
|
16
|
+
afterName: string;
|
|
17
|
+
equal: string;
|
|
18
|
+
beforeValue: string;
|
|
19
|
+
startQuote: string;
|
|
20
|
+
value: string;
|
|
21
|
+
endQuote: string;
|
|
22
|
+
afterAttr: string;
|
|
26
23
|
};
|
|
27
24
|
export {};
|
package/lib/parser-error.d.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
export type ParserErrorInfo = {
|
|
2
|
+
readonly line?: number;
|
|
3
|
+
readonly col?: number;
|
|
4
|
+
readonly raw?: string;
|
|
5
|
+
};
|
|
1
6
|
export declare class ParserError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
readonly col: number;
|
|
8
|
+
readonly line: number;
|
|
9
|
+
name: string;
|
|
10
|
+
readonly raw: string;
|
|
11
|
+
constructor(message: string, info: ParserErrorInfo);
|
|
12
|
+
}
|
|
13
|
+
export declare class TargetParserError extends ParserError {
|
|
14
|
+
name: string;
|
|
15
|
+
readonly nodeName: string | null;
|
|
16
|
+
constructor(message: string, info: ParserErrorInfo & {
|
|
17
|
+
readonly nodeName?: string | null;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export declare class ConfigParserError extends ParserError {
|
|
21
|
+
readonly filePath: string;
|
|
22
|
+
name: string;
|
|
23
|
+
constructor(message: string, info: ParserErrorInfo & {
|
|
24
|
+
readonly filePath: string;
|
|
25
|
+
});
|
|
21
26
|
}
|
package/lib/parser-error.js
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParserError = void 0;
|
|
3
|
+
exports.ConfigParserError = exports.TargetParserError = exports.ParserError = void 0;
|
|
4
4
|
class ParserError extends Error {
|
|
5
|
-
constructor(message,
|
|
6
|
-
|
|
5
|
+
constructor(message, info) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
super(message);
|
|
7
8
|
this.name = 'ParserError';
|
|
8
|
-
this.line = line;
|
|
9
|
-
this.col = col;
|
|
10
|
-
this.raw = raw;
|
|
11
|
-
this.nodeName = nodeName;
|
|
9
|
+
this.line = (_a = info.line) !== null && _a !== void 0 ? _a : 1;
|
|
10
|
+
this.col = (_b = info.col) !== null && _b !== void 0 ? _b : 0;
|
|
11
|
+
this.raw = (_c = info.raw) !== null && _c !== void 0 ? _c : '';
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.ParserError = ParserError;
|
|
15
|
+
class TargetParserError extends ParserError {
|
|
16
|
+
constructor(message, info) {
|
|
17
|
+
var _a;
|
|
18
|
+
const errMsg = info.nodeName
|
|
19
|
+
? `The ${info.nodeName} is invalid element (${info.line}:${info.col}): ${message}`
|
|
20
|
+
: message;
|
|
21
|
+
super(errMsg, info);
|
|
22
|
+
this.name = 'TargetParserError';
|
|
23
|
+
this.nodeName = (_a = info.nodeName) !== null && _a !== void 0 ? _a : null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.TargetParserError = TargetParserError;
|
|
27
|
+
class ConfigParserError extends ParserError {
|
|
28
|
+
constructor(message, info) {
|
|
29
|
+
const pos = info.line != null && info.line != null ? `(${info.line}:${info.col})` : '';
|
|
30
|
+
const file = ` in ${info.filePath}${pos}`;
|
|
31
|
+
const errMsg = `${message}${file}`;
|
|
32
|
+
super(errMsg, info);
|
|
33
|
+
this.name = 'ConfigParserError';
|
|
34
|
+
this.filePath = info.filePath;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ConfigParserError = ConfigParserError;
|
package/lib/tag-splitter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface N {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type: 'text' | 'starttag' | 'endtag' | 'comment' | 'boguscomment';
|
|
3
|
+
raw: string;
|
|
4
|
+
line: number;
|
|
5
|
+
col: number;
|
|
6
6
|
}
|
|
7
7
|
export default function tagSplitter(raw: string, line: number, col: number): N[];
|
package/lib/types.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export type Code = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly index: number;
|
|
4
|
+
readonly startTag: string;
|
|
5
|
+
readonly taggedCode: string;
|
|
6
|
+
readonly endTag: string | null;
|
|
7
7
|
};
|
|
8
8
|
export type IgnoreTag = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly start: Readonly<RegExp>;
|
|
11
|
+
readonly end: Readonly<RegExp>;
|
|
12
12
|
};
|
|
13
13
|
export type IgnoreBlock = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly replaced: string;
|
|
16
|
+
readonly stack: readonly Code[];
|
|
17
|
+
readonly 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.10.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>",
|
|
@@ -19,15 +19,12 @@
|
|
|
19
19
|
"clean": "tsc --build --clean"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@markuplint/ml-ast": "3.
|
|
23
|
-
"@markuplint/types": "3.
|
|
24
|
-
"@types/uuid": "^9.0.
|
|
25
|
-
"tslib": "^2.
|
|
26
|
-
"type-fest": "^3.
|
|
22
|
+
"@markuplint/ml-ast": "3.2.0",
|
|
23
|
+
"@markuplint/types": "3.9.0",
|
|
24
|
+
"@types/uuid": "^9.0.2",
|
|
25
|
+
"tslib": "^2.6.0",
|
|
26
|
+
"type-fest": "^3.12.0",
|
|
27
27
|
"uuid": "^9.0.0"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"@markuplint/ml-core": "3.x"
|
|
31
|
-
},
|
|
32
|
-
"gitHead": "af370797bfc887e5a5a2ff57fbaa8392ac98ead2"
|
|
29
|
+
"gitHead": "4ab20276db48a6acb29a923ea8666890ca853442"
|
|
33
30
|
}
|