@markuplint/parser-utils 3.4.0 → 3.5.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 CHANGED
@@ -1,7 +1,10 @@
1
- export declare const MASK_CHAR = '\uE000';
1
+ export declare const MASK_CHAR = "\uE000";
2
2
  /**
3
3
  * SVG Element list
4
4
  *
5
5
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element
6
6
  */
7
7
  export declare const svgElementList: string[];
8
+ export declare const reTag: RegExp;
9
+ export declare const reTagName: RegExp;
10
+ export declare const reSplitterTag: RegExp;
package/lib/const.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.svgElementList = exports.MASK_CHAR = void 0;
3
+ exports.reSplitterTag = exports.reTagName = exports.reTag = exports.svgElementList = exports.MASK_CHAR = void 0;
4
4
  exports.MASK_CHAR = '\uE000';
5
5
  /**
6
6
  * SVG Element list
@@ -97,3 +97,7 @@ exports.svgElementList = [
97
97
  'tref',
98
98
  'vkern',
99
99
  ];
100
+ exports.reTag = /^<((?:.|\s|\n)+)>\s*$/;
101
+ // eslint-disable-next-line no-control-regex
102
+ exports.reTagName = /^(?:[a-z][^\u0000\u0009\u000A\u000C\u0020/>]*)/i;
103
+ exports.reSplitterTag = /<[^>]+>/g;
@@ -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;
package/lib/debugger.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.attributesToDebugMaps = exports.nodeListToDebugMaps = void 0;
4
- function nodeListToDebugMaps(nodeList, withAttr = false) {
4
+ function nodeListToDebugMaps(
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ nodeList, withAttr = false) {
5
7
  return nodeList
6
8
  .map(n => {
7
9
  const r = [];
@@ -19,7 +21,9 @@ function nodeListToDebugMaps(nodeList, withAttr = false) {
19
21
  .flat();
20
22
  }
21
23
  exports.nodeListToDebugMaps = nodeListToDebugMaps;
22
- function attributesToDebugMaps(attributes) {
24
+ function attributesToDebugMaps(
25
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
26
+ attributes) {
23
27
  return attributes.map(n => {
24
28
  const r = [
25
29
  tokenDebug({
@@ -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;
@@ -0,0 +1,2 @@
1
+ import type { MLASTNode } from '@markuplint/ml-ast';
2
+ export declare function flattenNodes(nodeTree: MLASTNode[], rawHtml: string, createLastText?: boolean): MLASTNode[];
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenNodes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const remove_deprecated_node_1 = require("./remove-deprecated-node");
6
+ const tag_splitter_1 = tslib_1.__importDefault(require("./tag-splitter"));
7
+ const parser_utils_1 = require("@markuplint/parser-utils");
8
+ function flattenNodes(
9
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
+ nodeTree, rawHtml, createLastText = true) {
11
+ const nodeOrders = arrayize(nodeTree, rawHtml);
12
+ {
13
+ /**
14
+ * Correction prev/next/parent
15
+ */
16
+ let prevToken = null;
17
+ for (const node of nodeOrders) {
18
+ if (!prevToken) {
19
+ prevToken = node;
20
+ continue;
21
+ }
22
+ if (node.type !== 'endtag') {
23
+ prevToken = node;
24
+ continue;
25
+ }
26
+ const endTag = node;
27
+ if (endTag.nodeName.toLowerCase() === 'body' && prevToken.type === 'text') {
28
+ const prevWreckagesText = prevToken;
29
+ if (prevWreckagesText) {
30
+ const wreckages = (0, tag_splitter_1.default)(prevWreckagesText.raw, prevWreckagesText.startLine, prevWreckagesText.startCol);
31
+ if (wreckages.length && wreckages[0]) {
32
+ // console.log('wreckages\n', wreckages);
33
+ const lastText = wreckages[0];
34
+ const raw = lastText.raw;
35
+ const startLine = lastText.line;
36
+ const startCol = lastText.col;
37
+ prevWreckagesText.raw = raw;
38
+ prevWreckagesText.endOffset = prevWreckagesText.startOffset + raw.length;
39
+ prevWreckagesText.startLine = startLine;
40
+ prevWreckagesText.endLine = (0, parser_utils_1.getEndLine)(raw, startLine);
41
+ prevWreckagesText.startCol = startCol;
42
+ prevWreckagesText.endCol = (0, parser_utils_1.getEndCol)(raw, startCol);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ (0, remove_deprecated_node_1.removeDeprecatedNode)(nodeOrders);
49
+ {
50
+ /**
51
+ * getting last node
52
+ */
53
+ let lastNode = null;
54
+ for (const node of nodeOrders) {
55
+ if (node.isGhost) {
56
+ continue;
57
+ }
58
+ lastNode = node;
59
+ }
60
+ if (lastNode) {
61
+ if (lastNode.type === 'text') {
62
+ // Correction for Parse5 AST
63
+ // prev node: ? -> html
64
+ lastNode.prevNode = lastNode.parentNode && lastNode.parentNode.parentNode;
65
+ if (lastNode.prevNode) {
66
+ lastNode.prevNode.nextNode = lastNode;
67
+ }
68
+ // parent node: body -> null
69
+ lastNode.parentNode = null;
70
+ // next node: ? -> null
71
+ lastNode.nextNode = null;
72
+ }
73
+ else if (createLastText) {
74
+ /**
75
+ * create Last spaces
76
+ */
77
+ let lastOffset = 0;
78
+ nodeOrders.forEach((node, i) => {
79
+ lastOffset = Math.max(node.endOffset, lastOffset);
80
+ });
81
+ // console.log(lastOffset);
82
+ const lastTextContent = rawHtml.slice(lastOffset);
83
+ // console.log(`"${lastTextContent}"`);
84
+ if (lastTextContent) {
85
+ const line = lastNode ? lastNode.endLine : 0;
86
+ const col = lastNode ? lastNode.endCol : 0;
87
+ const lastTextNode = {
88
+ uuid: (0, parser_utils_1.uuid)(),
89
+ raw: lastTextContent,
90
+ startOffset: lastOffset,
91
+ endOffset: lastOffset + lastTextContent.length,
92
+ startLine: line,
93
+ endLine: (0, parser_utils_1.getEndLine)(lastTextContent, line),
94
+ startCol: col,
95
+ endCol: (0, parser_utils_1.getEndCol)(lastTextContent, col),
96
+ nodeName: '#text',
97
+ type: 'text',
98
+ parentNode: null,
99
+ prevNode: lastNode,
100
+ nextNode: null,
101
+ isFragment: false,
102
+ isGhost: false,
103
+ };
104
+ if (lastNode) {
105
+ lastNode.nextNode = lastTextNode;
106
+ if ((lastNode.type === 'starttag' || lastNode.type === 'endtag') && lastNode.pearNode) {
107
+ lastNode.pearNode.nextNode = lastTextNode;
108
+ }
109
+ }
110
+ nodeOrders.push(lastTextNode);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * concat text nodes
117
+ */
118
+ const result = [];
119
+ nodeOrders.forEach(node => {
120
+ const prevNode = result[result.length - 1] || null;
121
+ if (node.type === 'text' && prevNode && prevNode.type === 'text') {
122
+ prevNode.raw = prevNode.raw + node.raw;
123
+ prevNode.endOffset = node.endOffset;
124
+ prevNode.endLine = node.endLine;
125
+ prevNode.endCol = node.endCol;
126
+ prevNode.nextNode = node.nextNode;
127
+ if (prevNode.parentNode && prevNode.parentNode.childNodes) {
128
+ prevNode.parentNode.childNodes = prevNode.parentNode.childNodes.filter(n => n.uuid !== node.uuid);
129
+ }
130
+ if (node.nextNode) {
131
+ node.nextNode.prevNode = prevNode;
132
+ }
133
+ return;
134
+ }
135
+ result.push(node);
136
+ });
137
+ {
138
+ /**
139
+ * Correction prev/next/parent
140
+ */
141
+ let prevToken = null;
142
+ for (const node of result) {
143
+ if (!prevToken) {
144
+ prevToken = node;
145
+ continue;
146
+ }
147
+ if (((prevToken.type === 'endtag' && prevToken.nodeName.toLowerCase() === 'body') ||
148
+ prevToken.type === 'doctype') &&
149
+ node.type === 'text') {
150
+ const nextNode = prevToken.nextNode;
151
+ prevToken.nextNode = node;
152
+ if (prevToken.type === 'endtag' && prevToken.pearNode) {
153
+ prevToken.pearNode.nextNode = node;
154
+ }
155
+ node.prevNode = prevToken;
156
+ node.nextNode = nextNode;
157
+ node.parentNode = prevToken.parentNode;
158
+ }
159
+ // EndTag
160
+ if (node.type === 'starttag' && node.pearNode) {
161
+ const endTag = node.pearNode;
162
+ endTag.pearNode = node;
163
+ endTag.prevNode = node.prevNode;
164
+ endTag.nextNode = node.nextNode;
165
+ }
166
+ // Children
167
+ if (node.type === 'text') {
168
+ const parent = node.parentNode;
169
+ if (parent && parent.type === 'starttag' && parent.nodeName.toLowerCase() === 'html') {
170
+ if (parent.childNodes && !parent.childNodes.some(n => n.uuid === node.uuid)) {
171
+ parent.childNodes.push(node);
172
+ }
173
+ }
174
+ }
175
+ prevToken = node;
176
+ }
177
+ }
178
+ // console.log(nodeOrders.map((n, i) => `${i}: ${n.raw.trim()}`));
179
+ return result;
180
+ }
181
+ exports.flattenNodes = flattenNodes;
182
+ function arrayize(
183
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
184
+ nodeTree, rawHtml) {
185
+ const nodeOrders = [];
186
+ let prevLine = 1;
187
+ let prevCol = 1;
188
+ let currentEndOffset = 0;
189
+ /**
190
+ * pushing list
191
+ */
192
+ (0, parser_utils_1.walk)(nodeTree, node => {
193
+ const diff = node.startOffset - currentEndOffset;
194
+ if (diff > 0) {
195
+ const html = rawHtml.slice(currentEndOffset, node.startOffset);
196
+ /**
197
+ * first white spaces
198
+ */
199
+ if (/^\s+$/.test(html)) {
200
+ const spaces = html;
201
+ const textNode = {
202
+ uuid: (0, parser_utils_1.uuid)(),
203
+ raw: spaces,
204
+ startOffset: currentEndOffset,
205
+ endOffset: currentEndOffset + spaces.length,
206
+ startLine: prevLine,
207
+ endLine: (0, parser_utils_1.getEndLine)(spaces, prevLine),
208
+ startCol: prevCol,
209
+ endCol: (0, parser_utils_1.getEndCol)(spaces, prevCol),
210
+ nodeName: '#text',
211
+ type: 'text',
212
+ parentNode: node.parentNode,
213
+ prevNode: node.prevNode,
214
+ nextNode: node,
215
+ isFragment: false,
216
+ isGhost: false,
217
+ };
218
+ node.prevNode = textNode;
219
+ if (node.parentNode && node.parentNode.childNodes) {
220
+ const newChildNodes = [...node.parentNode.childNodes];
221
+ if (newChildNodes.some(child => {
222
+ return (
223
+ // Out of start offset
224
+ textNode.endOffset < child.startOffset ||
225
+ // Out of end offset
226
+ child.endOffset < textNode.startOffset);
227
+ })) {
228
+ newChildNodes.push(textNode);
229
+ }
230
+ newChildNodes.sort((a, b) => a.startOffset - b.startOffset);
231
+ node.parentNode.childNodes = newChildNodes;
232
+ }
233
+ nodeOrders.push(textNode);
234
+ }
235
+ }
236
+ currentEndOffset = node.startOffset + node.raw.length;
237
+ prevLine = node.endLine;
238
+ prevCol = node.endCol;
239
+ // for ghost nodes
240
+ node.startOffset = node.startOffset || node.startOffset;
241
+ node.endOffset = node.endOffset || currentEndOffset;
242
+ nodeOrders.push(node);
243
+ });
244
+ return nodeOrders.slice();
245
+ }
@@ -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
- 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;
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,4 +1,4 @@
1
1
  export declare function searchIDLAttribute(name: string): {
2
- idlPropName: string | undefined;
3
- contentAttrName: string | undefined;
2
+ idlPropName: string | undefined;
3
+ contentAttrName: string | undefined;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  import type { IgnoreBlock, IgnoreTag } from './types';
2
2
  import type { MLASTNode } from '@markuplint/ml-ast';
3
- export declare function ignoreBlock(source: string, tags: IgnoreTag[], maskChar?: string): IgnoreBlock;
3
+ export declare function ignoreBlock(source: string, tags: readonly IgnoreTag[], maskChar?: string): IgnoreBlock;
4
4
  export declare function restoreNode(nodeList: MLASTNode[], ignoreBlock: IgnoreBlock): MLASTNode[];
@@ -64,7 +64,9 @@ function maskText(start, end, replaced, masking) {
64
64
  stack,
65
65
  };
66
66
  }
67
- function restoreNode(nodeList, ignoreBlock) {
67
+ function restoreNode(
68
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
69
+ nodeList, ignoreBlock) {
68
70
  var _a, _b, _c, _d;
69
71
  nodeList = nodeList.slice();
70
72
  const { source, stack, maskChar } = ignoreBlock;
package/lib/index.d.ts CHANGED
@@ -1,10 +1,14 @@
1
+ export * from './const';
2
+ export * from './create-token';
3
+ export * from './debugger';
1
4
  export * from './decision';
5
+ export * from './detect-element-type';
6
+ export * from './flatten-nodes';
2
7
  export * from './get-location';
3
- export * from './create-token';
4
8
  export * from './idl-attributes';
5
- export * from './walker';
6
9
  export * from './ignore-block';
7
10
  export * from './ignore-front-matter';
8
- export * from './debugger';
9
11
  export * from './parser-error';
10
- export * from './detect-element-type';
12
+ export * from './remove-deprecated-node';
13
+ export * from './tag-splitter';
14
+ export * from './walker';
package/lib/index.js CHANGED
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./const"), exports);
5
+ tslib_1.__exportStar(require("./create-token"), exports);
6
+ tslib_1.__exportStar(require("./debugger"), exports);
4
7
  tslib_1.__exportStar(require("./decision"), exports);
8
+ tslib_1.__exportStar(require("./detect-element-type"), exports);
9
+ tslib_1.__exportStar(require("./flatten-nodes"), exports);
5
10
  tslib_1.__exportStar(require("./get-location"), exports);
6
- tslib_1.__exportStar(require("./create-token"), exports);
7
11
  tslib_1.__exportStar(require("./idl-attributes"), exports);
8
- tslib_1.__exportStar(require("./walker"), exports);
9
12
  tslib_1.__exportStar(require("./ignore-block"), exports);
10
13
  tslib_1.__exportStar(require("./ignore-front-matter"), exports);
11
- tslib_1.__exportStar(require("./debugger"), exports);
12
14
  tslib_1.__exportStar(require("./parser-error"), exports);
13
- tslib_1.__exportStar(require("./detect-element-type"), exports);
15
+ tslib_1.__exportStar(require("./remove-deprecated-node"), exports);
16
+ tslib_1.__exportStar(require("./tag-splitter"), exports);
17
+ tslib_1.__exportStar(require("./walker"), exports);
@@ -1,21 +1,13 @@
1
1
  export declare class ParserError extends Error {
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
- );
2
+ readonly col: number;
3
+ readonly line: number;
4
+ name: string;
5
+ readonly nodeName: string | null;
6
+ readonly raw: string;
7
+ constructor(message: string, { line, col, raw, nodeName, }: {
8
+ readonly line?: number;
9
+ readonly col?: number;
10
+ readonly raw?: string;
11
+ readonly nodeName?: string | null;
12
+ });
21
13
  }
@@ -0,0 +1,7 @@
1
+ import type { MLASTNode } from '@markuplint/ml-ast';
2
+ /**
3
+ *
4
+ * @disruptive
5
+ * @param nodeOrders [Disruptive change]
6
+ */
7
+ export declare function removeDeprecatedNode(nodeOrders: MLASTNode[]): void;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeDeprecatedNode = void 0;
4
+ /**
5
+ *
6
+ * @disruptive
7
+ * @param nodeOrders [Disruptive change]
8
+ */
9
+ function removeDeprecatedNode(
10
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
+ nodeOrders) {
12
+ /**
13
+ * sorting
14
+ */
15
+ nodeOrders.sort((a, b) => {
16
+ if (a.isGhost || b.isGhost) {
17
+ return 0;
18
+ }
19
+ return a.startOffset - b.startOffset;
20
+ });
21
+ /**
22
+ * remove duplicated node
23
+ */
24
+ const stack = {};
25
+ const removeIndexes = [];
26
+ nodeOrders.forEach((node, i) => {
27
+ if (node.isGhost) {
28
+ return;
29
+ }
30
+ const id = `${node.startLine}:${node.startCol}:${node.endLine}:${node.endCol}`;
31
+ if (stack[id] != null) {
32
+ removeIndexes.push(i);
33
+ }
34
+ stack[id] = i;
35
+ });
36
+ let r = nodeOrders.length;
37
+ while (r--) {
38
+ if (removeIndexes.includes(r)) {
39
+ nodeOrders.splice(r, 1);
40
+ }
41
+ }
42
+ }
43
+ exports.removeDeprecatedNode = removeDeprecatedNode;
@@ -8,7 +8,9 @@ exports.siblingsCorrection = void 0;
8
8
  * @affects nodeList[].prevNode
9
9
  * @affects nodeList[].nextNode
10
10
  */
11
- function siblingsCorrection(nodeList) {
11
+ function siblingsCorrection(
12
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13
+ nodeList) {
12
14
  for (let i = 0; i < nodeList.length; i++) {
13
15
  const prevNode = nodeList[i - 1] || null;
14
16
  const node = nodeList[i];
@@ -0,0 +1,7 @@
1
+ export interface N {
2
+ type: 'text' | 'starttag' | 'endtag' | 'comment' | 'boguscomment';
3
+ raw: string;
4
+ line: number;
5
+ col: number;
6
+ }
7
+ export default function tagSplitter(raw: string, line: number, col: number): N[];
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const const_1 = require("./const");
4
+ const parser_utils_1 = require("@markuplint/parser-utils");
5
+ function tagSplitter(raw, line, col) {
6
+ return withLocation(tagSplitterAsString(raw), line, col);
7
+ }
8
+ exports.default = tagSplitter;
9
+ function tagSplitterAsString(raw) {
10
+ const tagMatches = raw.match(const_1.reSplitterTag);
11
+ if (!tagMatches) {
12
+ return [raw];
13
+ }
14
+ const tokens = Array.from(tagMatches);
15
+ tokens.unshift(); // remove all match
16
+ const nodes = [];
17
+ let rest = raw;
18
+ for (const token of tokens) {
19
+ const index = rest.indexOf(token);
20
+ let length = token.length;
21
+ if (index > 0) {
22
+ const text = rest.slice(0, index);
23
+ nodes.push(text);
24
+ length += text.length;
25
+ }
26
+ nodes.push(token);
27
+ rest = rest.slice(length);
28
+ }
29
+ if (rest) {
30
+ nodes.push(rest);
31
+ }
32
+ return nodes;
33
+ }
34
+ function withLocation(nodes, line, col) {
35
+ const result = [];
36
+ for (const node of nodes) {
37
+ if (node[0] !== '<') {
38
+ result.push({
39
+ type: 'text',
40
+ raw: node,
41
+ line,
42
+ col,
43
+ });
44
+ }
45
+ else {
46
+ const label = node.slice(1).slice(0, -1);
47
+ if (const_1.reTagName.test(label)) {
48
+ result.push({
49
+ type: 'starttag',
50
+ raw: node,
51
+ line,
52
+ col,
53
+ });
54
+ }
55
+ else if (label[0] === '/') {
56
+ result.push({
57
+ type: 'endtag',
58
+ raw: node,
59
+ line,
60
+ col,
61
+ });
62
+ }
63
+ else if (label[0] === '!') {
64
+ result.push({
65
+ type: 'comment',
66
+ raw: node,
67
+ line,
68
+ col,
69
+ });
70
+ }
71
+ else if (label[0] === '?') {
72
+ result.push({
73
+ type: 'boguscomment',
74
+ raw: node,
75
+ line,
76
+ col,
77
+ });
78
+ }
79
+ else {
80
+ result.push({
81
+ type: 'text',
82
+ raw: node,
83
+ line,
84
+ col,
85
+ });
86
+ }
87
+ }
88
+ line = (0, parser_utils_1.getEndLine)(node, line);
89
+ col = (0, parser_utils_1.getEndCol)(node, col);
90
+ }
91
+ return result;
92
+ }
package/lib/types.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  export type Code = {
2
- type: string;
3
- index: number;
4
- startTag: string;
5
- taggedCode: string;
6
- endTag: string | null;
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
- type: string;
10
- start: RegExp;
11
- end: RegExp;
9
+ readonly type: string;
10
+ readonly start: Readonly<RegExp>;
11
+ readonly end: Readonly<RegExp>;
12
12
  };
13
13
  export type IgnoreBlock = {
14
- source: string;
15
- replaced: string;
16
- stack: Code[];
17
- maskChar: string;
14
+ readonly source: string;
15
+ readonly replaced: string;
16
+ readonly stack: readonly Code[];
17
+ readonly maskChar: string;
18
18
  };
package/lib/walker.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { MLASTNode, Walker } from '@markuplint/ml-ast';
2
- export declare function walk(nodeList: MLASTNode[], walker: Walker, depth?: number): void;
2
+ export declare function walk(nodeList: readonly MLASTNode[], walker: Walker, depth?: number): void;
package/lib/walker.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.walk = void 0;
4
- function walk(nodeList, walker, depth = 0) {
4
+ function walk(
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ nodeList, walker, depth = 0) {
5
7
  for (const node of nodeList) {
6
8
  walker(node, depth);
7
9
  if ('childNodes' in node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/parser-utils",
3
- "version": "3.4.0",
3
+ "version": "3.5.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,16 +19,17 @@
19
19
  "clean": "tsc --build --clean"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/uuid": "^9.0.0"
22
+ "@types/uuid": "^9.0.0",
23
+ "type-fest": "^3.7.0"
23
24
  },
24
25
  "dependencies": {
25
- "@markuplint/ml-ast": "3.0.0",
26
- "@markuplint/types": "3.3.0",
26
+ "@markuplint/ml-ast": "3.1.0",
27
+ "@markuplint/types": "3.4.0",
27
28
  "tslib": "^2.4.1",
28
29
  "uuid": "^9.0.0"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "@markuplint/ml-core": "3.x"
32
33
  },
33
- "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
34
+ "gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
34
35
  }