@markuplint/parser-utils 4.8.11 → 5.0.0-alpha.1
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/ARCHITECTURE.ja.md +6 -6
- package/ARCHITECTURE.md +5 -5
- package/CHANGELOG.md +37 -0
- package/docs/parser-class.ja.md +7 -7
- package/docs/parser-class.md +7 -7
- package/lib/debug.js +8 -24
- package/lib/debugger.js +9 -4
- package/lib/get-location.d.ts +31 -0
- package/lib/get-location.js +33 -0
- package/lib/get-namespace.d.ts +9 -0
- package/lib/get-namespace.js +9 -0
- package/lib/ignore-block.js +15 -14
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/parser-error.js +8 -3
- package/lib/parser.d.ts +12 -16
- package/lib/parser.js +526 -551
- package/lib/sort-nodes.d.ts +8 -0
- package/lib/sort-nodes.js +11 -3
- package/lib/types.d.ts +3 -3
- package/package.json +11 -10
package/lib/sort-nodes.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { MLASTNodeTreeItem } from '@markuplint/ml-ast';
|
|
2
|
+
/**
|
|
3
|
+
* Comparator function for sorting AST nodes by their source position.
|
|
4
|
+
* Sorts primarily by offset, then by end offset for nodes at the same position.
|
|
5
|
+
*
|
|
6
|
+
* @param a - The first node to compare
|
|
7
|
+
* @param b - The second node to compare
|
|
8
|
+
* @returns A negative, zero, or positive number for sort ordering
|
|
9
|
+
*/
|
|
2
10
|
export declare function sortNodes(a: MLASTNodeTreeItem, b: MLASTNodeTreeItem): number;
|
package/lib/sort-nodes.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comparator function for sorting AST nodes by their source position.
|
|
3
|
+
* Sorts primarily by offset, then by end offset for nodes at the same position.
|
|
4
|
+
*
|
|
5
|
+
* @param a - The first node to compare
|
|
6
|
+
* @param b - The second node to compare
|
|
7
|
+
* @returns A negative, zero, or positive number for sort ordering
|
|
8
|
+
*/
|
|
1
9
|
export function sortNodes(a, b) {
|
|
2
|
-
if (a.
|
|
3
|
-
return sort(a.
|
|
10
|
+
if (a.offset === b.offset) {
|
|
11
|
+
return sort(a.offset + a.raw.length, b.offset + b.raw.length);
|
|
4
12
|
}
|
|
5
|
-
return sort(a.
|
|
13
|
+
return sort(a.offset, b.offset);
|
|
6
14
|
}
|
|
7
15
|
function sort(a, b) {
|
|
8
16
|
const diff = a - b;
|
package/lib/types.d.ts
CHANGED
|
@@ -41,9 +41,9 @@ export type Tokenized<N extends {} = {}, State extends unknown = null> = {
|
|
|
41
41
|
*/
|
|
42
42
|
export type Token = {
|
|
43
43
|
readonly raw: string;
|
|
44
|
-
readonly
|
|
45
|
-
readonly
|
|
46
|
-
readonly
|
|
44
|
+
readonly offset: number;
|
|
45
|
+
readonly line: number;
|
|
46
|
+
readonly col: number;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
* A token that belongs to a parent node in the AST, extending the base Token
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/parser-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.1",
|
|
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>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
8
11
|
"type": "module",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
@@ -28,17 +31,15 @@
|
|
|
28
31
|
"clean": "tsc --build --clean tsconfig.build.json"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@markuplint/ml-ast": "
|
|
32
|
-
"@markuplint/ml-spec": "
|
|
33
|
-
"@markuplint/types": "
|
|
34
|
-
"@types/uuid": "11.0.0",
|
|
34
|
+
"@markuplint/ml-ast": "5.0.0-alpha.1",
|
|
35
|
+
"@markuplint/ml-spec": "5.0.0-alpha.1",
|
|
36
|
+
"@markuplint/types": "5.0.0-alpha.1",
|
|
35
37
|
"debug": "4.4.3",
|
|
36
|
-
"espree": "11.1.
|
|
37
|
-
"type-fest": "4.
|
|
38
|
-
"uuid": "13.0.0"
|
|
38
|
+
"espree": "11.1.1",
|
|
39
|
+
"type-fest": "5.4.4"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@typescript-eslint/typescript-estree": "8.
|
|
42
|
+
"@typescript-eslint/typescript-estree": "8.56.0"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "78a295e73a097a1ce09c777c06fa21ab68136387"
|
|
44
45
|
}
|