@markuplint/parser-utils 1.6.3 → 2.0.0-dev.23

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.
@@ -0,0 +1,405 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchIDLAttribute = void 0;
4
+ /**
5
+ * IDL attributes VS Content attributes
6
+ */
7
+ const idlContentMap = {
8
+ // HTML
9
+ accept: 'accept',
10
+ acceptCharset: 'acceptcharset',
11
+ accessKey: 'accesskey',
12
+ action: 'action',
13
+ allowFullScreen: 'allowfullscreen',
14
+ alt: 'alt',
15
+ as: 'as',
16
+ async: 'async',
17
+ autoCapitalize: 'autocapitalize',
18
+ autoComplete: 'autocomplete',
19
+ autoCorrect: 'autocorrect',
20
+ autoFocus: 'autofocus',
21
+ autoPlay: 'autoplay',
22
+ autoSave: 'autosave',
23
+ capture: 'capture',
24
+ cellPadding: 'cellpadding',
25
+ cellSpacing: 'cellspacing',
26
+ challenge: 'challenge',
27
+ charSet: 'charset',
28
+ checked: 'checked',
29
+ cite: 'cite',
30
+ classID: 'classid',
31
+ className: 'class',
32
+ cols: 'cols',
33
+ colSpan: 'colspan',
34
+ content: 'content',
35
+ contentEditable: 'contenteditable',
36
+ contextMenu: 'contextmenu',
37
+ controls: 'controls',
38
+ controlsList: 'controlslist',
39
+ coords: 'coords',
40
+ crossOrigin: 'crossorigin',
41
+ data: 'data',
42
+ dateTime: 'datetime',
43
+ default: 'default',
44
+ defer: 'defer',
45
+ dir: 'dir',
46
+ disabled: 'disabled',
47
+ disablePictureInPicture: 'disablepictureinpicture',
48
+ disableRemotePlayback: 'disableremoteplayback',
49
+ download: 'download',
50
+ draggable: 'draggable',
51
+ encType: 'enctype',
52
+ enterKeyHint: 'enterkeyhint',
53
+ form: 'form',
54
+ formAction: 'formaction',
55
+ formEncType: 'formenctype',
56
+ formMethod: 'formmethod',
57
+ formNoValidate: 'formnovalidate',
58
+ formTarget: 'formtarget',
59
+ frameBorder: 'frameborder',
60
+ headers: 'headers',
61
+ height: 'height',
62
+ hidden: 'hidden',
63
+ high: 'high',
64
+ href: 'href',
65
+ hrefLang: 'hreflang',
66
+ htmlFor: 'for',
67
+ httpEquiv: 'httpequiv',
68
+ icon: 'icon',
69
+ id: 'id',
70
+ inputMode: 'inputmode',
71
+ integrity: 'integrity',
72
+ is: 'is',
73
+ itemID: 'itemid',
74
+ itemProp: 'itemprop',
75
+ itemRef: 'itemref',
76
+ itemScope: 'itemscope',
77
+ itemType: 'itemtype',
78
+ keyParams: 'keyparams',
79
+ keyType: 'keytype',
80
+ kind: 'kind',
81
+ label: 'label',
82
+ lang: 'lang',
83
+ list: 'list',
84
+ loop: 'loop',
85
+ low: 'low',
86
+ manifest: 'manifest',
87
+ marginHeight: 'marginheight',
88
+ marginWidth: 'marginwidth',
89
+ max: 'max',
90
+ maxLength: 'maxlength',
91
+ media: 'media',
92
+ mediaGroup: 'mediagroup',
93
+ method: 'method',
94
+ min: 'min',
95
+ minLength: 'minlength',
96
+ multiple: 'multiple',
97
+ muted: 'muted',
98
+ name: 'name',
99
+ noModule: 'nomodule',
100
+ nonce: 'nonce',
101
+ noValidate: 'novalidate',
102
+ open: 'open',
103
+ optimum: 'optimum',
104
+ pattern: 'pattern',
105
+ placeholder: 'placeholder',
106
+ playsInline: 'playsinline',
107
+ poster: 'poster',
108
+ preload: 'preload',
109
+ profile: 'profile',
110
+ radioGroup: 'radiogroup',
111
+ readOnly: 'readonly',
112
+ referrerPolicy: 'referrerpolicy',
113
+ rel: 'rel',
114
+ required: 'required',
115
+ reversed: 'reversed',
116
+ role: 'role',
117
+ rows: 'rows',
118
+ rowSpan: 'rowspan',
119
+ sandbox: 'sandbox',
120
+ scope: 'scope',
121
+ scoped: 'scoped',
122
+ scrolling: 'scrolling',
123
+ seamless: 'seamless',
124
+ selected: 'selected',
125
+ shape: 'shape',
126
+ size: 'size',
127
+ sizes: 'sizes',
128
+ span: 'span',
129
+ spellCheck: 'spellcheck',
130
+ src: 'src',
131
+ srcDoc: 'srcdoc',
132
+ srcLang: 'srclang',
133
+ srcSet: 'srcset',
134
+ start: 'start',
135
+ step: 'step',
136
+ style: 'style',
137
+ summary: 'summary',
138
+ tabIndex: 'tabindex',
139
+ target: 'target',
140
+ title: 'title',
141
+ type: 'type',
142
+ useMap: 'usemap',
143
+ value: 'value',
144
+ width: 'width',
145
+ wmode: 'wmode',
146
+ wrap: 'wrap',
147
+ // SVG
148
+ accentHeight: 'accent-height',
149
+ accumulate: 'accumulate',
150
+ additive: 'additive',
151
+ alignmentBaseline: 'alignment-baseline',
152
+ alphabetic: 'alphabetic',
153
+ amplitude: 'amplitude',
154
+ arabicForm: 'arabic-form',
155
+ ascent: 'ascent',
156
+ attributeName: 'attributeName',
157
+ attributeType: 'attributeType',
158
+ azimuth: 'azimuth',
159
+ baseFrequency: 'baseFrequency',
160
+ baselineShift: 'baseline-shift',
161
+ baseProfile: 'baseProfile',
162
+ bbox: 'bbox',
163
+ begin: 'begin',
164
+ bias: 'bias',
165
+ by: 'by',
166
+ calcMode: 'calcMode',
167
+ capHeight: 'cap-height',
168
+ clip: 'clip',
169
+ clipPath: 'clipPathUnits',
170
+ clipPathUnits: 'clip-path',
171
+ clipRule: 'clip-rule',
172
+ color: 'color',
173
+ colorInterpolation: 'color-interpolation',
174
+ colorInterpolationFilters: 'color-interpolation-filters',
175
+ colorProfile: 'color-profile',
176
+ colorRendering: 'color-rendering',
177
+ contentScriptType: 'contentScriptType',
178
+ contentStyleType: 'contentStyleType',
179
+ cursor: 'cursor',
180
+ cx: 'cx',
181
+ cy: 'cy',
182
+ d: 'd',
183
+ decelerate: 'decelerate',
184
+ descent: 'descent',
185
+ diffuseConstant: 'diffuseConstant',
186
+ direction: 'direction',
187
+ display: 'display',
188
+ divisor: 'divisor',
189
+ dominantBaseline: 'dominant-baseline',
190
+ dur: 'dur',
191
+ dx: 'dx',
192
+ dy: 'dy',
193
+ edgeMode: 'edgeMode',
194
+ elevation: 'elevation',
195
+ enableBackground: 'enable-background',
196
+ end: 'end',
197
+ exponent: 'exponent',
198
+ fill: 'fill',
199
+ fillOpacity: 'fill-opacity',
200
+ fillRule: 'fill-rule',
201
+ filter: 'filter',
202
+ filterRes: 'filterRes',
203
+ filterUnits: 'filterUnits',
204
+ floodColor: 'flood-color',
205
+ floodOpacity: 'flood-opacity',
206
+ focusable: 'focusable',
207
+ fontFamily: 'font-family',
208
+ fontSize: 'font-size',
209
+ fontSizeAdjust: 'font-size-adjust',
210
+ fontStretch: 'font-stretch',
211
+ fontStyle: 'font-style',
212
+ fontVariant: 'font-variant',
213
+ fontWeight: 'font-weight',
214
+ format: 'format',
215
+ from: 'from',
216
+ fr: 'fr',
217
+ fx: 'fx',
218
+ fy: 'fy',
219
+ g1: 'g1',
220
+ g2: 'g2',
221
+ glyphName: 'glyph-name',
222
+ glyphOrientationHorizontal: 'glyph-orientation-horizontal',
223
+ glyphOrientationVertical: 'glyph-orientation-vertical',
224
+ glyphRef: 'glyphRef',
225
+ gradientTransform: 'gradientTransform',
226
+ gradientUnits: 'gradientUnits',
227
+ hanging: 'hanging',
228
+ horizAdvX: 'horiz-adv-x',
229
+ horizOriginX: 'horiz-origin-x',
230
+ ideographic: 'ideographic',
231
+ imageRendering: 'image-rendering',
232
+ in: 'in',
233
+ in2: 'in2',
234
+ intercept: 'intercept',
235
+ k: 'k',
236
+ k1: 'k1',
237
+ k2: 'k2',
238
+ k3: 'k3',
239
+ k4: 'k4',
240
+ kernelMatrix: 'kernelMatrix',
241
+ kernelUnitLength: 'kernelUnitLength',
242
+ kerning: 'kerning',
243
+ keyPoints: 'keyPoints',
244
+ keySplines: 'keySplines',
245
+ keyTimes: 'keyTimes',
246
+ lengthAdjust: 'lengthAdjust',
247
+ letterSpacing: 'letter-spacing',
248
+ lightingColor: 'lighting-color',
249
+ limitingConeAngle: 'limitingConeAngle',
250
+ local: 'local',
251
+ markerEnd: 'marker-end',
252
+ markerHeight: 'markerHeight',
253
+ markerMid: 'marker-mid',
254
+ markerStart: 'marker-start',
255
+ markerUnits: 'markerUnits',
256
+ markerWidth: 'markerWidth',
257
+ mask: 'mask',
258
+ maskContentUnits: 'maskContentUnits',
259
+ maskUnits: 'maskUnits',
260
+ mathematical: 'mathematical',
261
+ mode: 'mode',
262
+ numOctaves: 'numOctaves',
263
+ offset: 'offset',
264
+ opacity: 'opacity',
265
+ operator: 'operator',
266
+ order: 'order',
267
+ orient: 'orient',
268
+ orientation: 'orientation',
269
+ origin: 'origin',
270
+ overflow: 'overflow',
271
+ overlinePosition: 'overline-position',
272
+ overlineThickness: 'overline-thickness',
273
+ paintOrder: 'paint-order',
274
+ panose1: 'panose-1',
275
+ pathLength: 'pathLength',
276
+ patternContentUnits: 'patternContentUnits',
277
+ patternTransform: 'patternTransform',
278
+ patternUnits: 'patternUnits',
279
+ pointerEvents: 'pointer-events',
280
+ points: 'points',
281
+ pointsAtX: 'pointsAtX',
282
+ pointsAtY: 'pointsAtY',
283
+ pointsAtZ: 'pointsAtZ',
284
+ preserveAlpha: 'preserveAlpha',
285
+ preserveAspectRatio: 'preserveAspectRatio',
286
+ primitiveUnits: 'primitiveUnits',
287
+ r: 'r',
288
+ refX: 'refX',
289
+ refY: 'refY',
290
+ renderingIntent: 'rendering-intent',
291
+ repeatCount: 'repeatCount',
292
+ repeatDur: 'repeatDur',
293
+ requiredExtensions: 'requiredExtensions',
294
+ requiredFeatures: 'requiredFeatures',
295
+ restart: 'restart',
296
+ result: 'result',
297
+ rotate: 'rotate',
298
+ rx: 'rx',
299
+ ry: 'ry',
300
+ scale: 'scale',
301
+ seed: 'seed',
302
+ shapeRendering: 'shape-rendering',
303
+ slope: 'slope',
304
+ spacing: 'spacing',
305
+ specularConstant: 'specularConstant',
306
+ specularExponent: 'specularExponent',
307
+ speed: 'speed',
308
+ spreadMethod: 'spreadMethod',
309
+ startOffset: 'startOffset',
310
+ stdDeviation: 'stdDeviation',
311
+ stemh: 'stemh',
312
+ stemv: 'stemv',
313
+ stitchTiles: 'stitchTiles',
314
+ stopColor: 'stop-color',
315
+ stopOpacity: 'stop-opacity',
316
+ strikethroughPosition: 'strikethrough-position',
317
+ strikethroughThickness: 'strikethrough-thickness',
318
+ string: 'string',
319
+ stroke: 'stroke',
320
+ strokeDasharray: 'stroke-dasharray',
321
+ strokeDashoffset: 'stroke-dashoffset',
322
+ strokeLinecap: 'stroke-linecap',
323
+ strokeLinejoin: 'stroke-linejoin',
324
+ strokeMiterlimit: 'stroke-miterlimit',
325
+ strokeOpacity: 'stroke-opacity',
326
+ strokeWidth: 'stroke-width',
327
+ surfaceScale: 'surfaceScale',
328
+ systemLanguage: 'systemLanguage',
329
+ tableValues: 'tableValues',
330
+ targetX: 'targetX',
331
+ targetY: 'targetY',
332
+ textAnchor: 'text-anchor',
333
+ textDecoration: 'text-decoration',
334
+ textLength: 'textLength',
335
+ textRendering: 'text-rendering',
336
+ to: 'to',
337
+ transform: 'transform',
338
+ transformOrigin: 'transform-origin',
339
+ u1: 'u1',
340
+ u2: 'u2',
341
+ underlinePosition: 'underline-position',
342
+ underlineThickness: 'underline-thickness',
343
+ unicode: 'unicode',
344
+ unicodeBidi: 'unicode-bidi',
345
+ unicodeRange: 'unicode-range',
346
+ unitsPerEm: 'units-per-em',
347
+ vAlphabetic: 'v-alphabetic',
348
+ values: 'values',
349
+ vectorEffect: 'vector-effect',
350
+ version: 'version',
351
+ vertAdvY: 'vert-adv-y',
352
+ vertOriginX: 'vert-origin-x',
353
+ vertOriginY: 'vert-origin-y',
354
+ vHanging: 'v-hanging',
355
+ vIdeographic: 'v-ideographic',
356
+ viewBox: 'viewBox',
357
+ viewTarget: 'viewTarget',
358
+ visibility: 'visibility',
359
+ vMathematical: 'v-mathematical',
360
+ widths: 'widths',
361
+ wordSpacing: 'word-spacing',
362
+ writingMode: 'writing-mode',
363
+ x: 'x',
364
+ x1: 'x1',
365
+ x2: 'x2',
366
+ xChannelSelector: 'xChannelSelector',
367
+ xHeight: 'x-height',
368
+ xlinkActuate: 'xlink:actuate',
369
+ xlinkArcrole: 'xlink:arcrole',
370
+ xlinkHref: 'xlink:href',
371
+ xlinkRole: 'xlink:role',
372
+ xlinkShow: 'xlink:show',
373
+ xlinkTitle: 'xlink:title',
374
+ xlinkType: 'xlink:type',
375
+ xmlBase: 'xml:base',
376
+ xmlLang: 'xml:lang',
377
+ xmlnsXlink: 'xmlns:xlink',
378
+ xmlSpace: 'xml:space',
379
+ y: 'y',
380
+ y1: 'y1',
381
+ y2: 'y1',
382
+ yChannelSelector: 'yChannelSelector',
383
+ z: 'z',
384
+ zoomAndPan: 'zoomAndPan',
385
+ };
386
+ const list = Object.entries(idlContentMap);
387
+ function searchIDLAttribute(name) {
388
+ const camelizedName = camelize(name);
389
+ const [idlPropName, contentAttrName] = (/^on[a-z]/.test(name) && [name.toLowerCase(), name.toLowerCase()]) ||
390
+ list.find(([idlPropName, contentAttrName]) => idlPropName.toLowerCase() === camelizedName.toLowerCase() ||
391
+ contentAttrName.toLowerCase() === name.toLowerCase() ||
392
+ hyphenize(idlPropName) === name.toLowerCase()) ||
393
+ [];
394
+ return {
395
+ idlPropName,
396
+ contentAttrName,
397
+ };
398
+ }
399
+ exports.searchIDLAttribute = searchIDLAttribute;
400
+ function camelize(str) {
401
+ return str.replace(/[:-][a-z]/g, $0 => $0[1].toUpperCase());
402
+ }
403
+ function hyphenize(str) {
404
+ return str.replace(/[A-Z]/g, $0 => `-${$0.toLowerCase()}`);
405
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const idl_attributes_1 = require("./idl-attributes");
4
+ it('basic', () => {
5
+ expect((0, idl_attributes_1.searchIDLAttribute)('class')).toStrictEqual({
6
+ idlPropName: 'className',
7
+ contentAttrName: 'class',
8
+ });
9
+ expect((0, idl_attributes_1.searchIDLAttribute)('for')).toStrictEqual({
10
+ idlPropName: 'htmlFor',
11
+ contentAttrName: 'for',
12
+ });
13
+ expect((0, idl_attributes_1.searchIDLAttribute)('className')).toStrictEqual({
14
+ idlPropName: 'className',
15
+ contentAttrName: 'class',
16
+ });
17
+ expect((0, idl_attributes_1.searchIDLAttribute)('htmlFor')).toStrictEqual({
18
+ idlPropName: 'htmlFor',
19
+ contentAttrName: 'for',
20
+ });
21
+ expect((0, idl_attributes_1.searchIDLAttribute)('tabindex')).toStrictEqual({
22
+ idlPropName: 'tabIndex',
23
+ contentAttrName: 'tabindex',
24
+ });
25
+ expect((0, idl_attributes_1.searchIDLAttribute)('tab-index')).toStrictEqual({
26
+ idlPropName: 'tabIndex',
27
+ contentAttrName: 'tabindex',
28
+ });
29
+ expect((0, idl_attributes_1.searchIDLAttribute)('TabIndex')).toStrictEqual({
30
+ idlPropName: 'tabIndex',
31
+ contentAttrName: 'tabindex',
32
+ });
33
+ expect((0, idl_attributes_1.searchIDLAttribute)('x')).toStrictEqual({
34
+ idlPropName: 'x',
35
+ contentAttrName: 'x',
36
+ });
37
+ expect((0, idl_attributes_1.searchIDLAttribute)('y')).toStrictEqual({
38
+ idlPropName: 'y',
39
+ contentAttrName: 'y',
40
+ });
41
+ expect((0, idl_attributes_1.searchIDLAttribute)('attribute-name')).toStrictEqual({
42
+ idlPropName: 'attributeName',
43
+ contentAttrName: 'attributeName',
44
+ });
45
+ });
@@ -1,4 +1,4 @@
1
- import { IgnoreBlock, IgnoreTag } from './types';
2
- import { MLASTNode } from '@markuplint/ml-ast';
1
+ import type { IgnoreBlock, IgnoreTag } from './types';
2
+ import type { MLASTNode } from '@markuplint/ml-ast';
3
3
  export declare function ignoreBlock(source: string, tags: IgnoreTag[]): IgnoreBlock;
4
4
  export declare function restoreNode(nodeList: MLASTNode[], ignoreBlock: IgnoreBlock): MLASTNode[];
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.restoreNode = exports.ignoreBlock = void 0;
4
- const ml_ast_1 = require("@markuplint/ml-ast");
5
- const utils_1 = require("./utils");
6
4
  const const_1 = require("./const");
5
+ const create_token_1 = require("./create-token");
6
+ const get_location_1 = require("./get-location");
7
+ const siblings_correction_1 = require("./siblings-correction");
7
8
  function ignoreBlock(source, tags) {
8
9
  let replaced = source;
9
10
  const stack = [];
@@ -16,7 +17,7 @@ function ignoreBlock(source, tags) {
16
17
  return mask;
17
18
  });
18
19
  replaced = attr.replaced;
19
- stack.push(...attr.stack.map(res => (Object.assign(Object.assign({}, res), { type: tag.type }))));
20
+ stack.push(...attr.stack.map(res => ({ ...res, type: tag.type })));
20
21
  // Replace tags in other nodes
21
22
  const text = maskText(tag.start, tag.end, replaced, (startTag, taggedCode, endTag) => {
22
23
  const mask = const_1.MASK_CHAR.repeat(startTag.length) +
@@ -26,7 +27,7 @@ function ignoreBlock(source, tags) {
26
27
  return taggedMask;
27
28
  });
28
29
  replaced = text.replaced;
29
- stack.push(...text.stack.map(res => (Object.assign(Object.assign({}, res), { type: tag.type }))));
30
+ stack.push(...text.stack.map(res => ({ ...res, type: tag.type })));
30
31
  }
31
32
  stack.sort((a, b) => a.index - b.index);
32
33
  return {
@@ -66,7 +67,7 @@ function restoreNode(nodeList, ignoreBlock) {
66
67
  nodeList = nodeList.slice();
67
68
  const { source, stack } = ignoreBlock;
68
69
  for (const node of nodeList) {
69
- if (node.type === ml_ast_1.MLASTNodeType.Comment || node.type === ml_ast_1.MLASTNodeType.Text) {
70
+ if (node.type === 'comment' || node.type === 'text') {
70
71
  if (!hasIgnoreBlock(node.raw)) {
71
72
  continue;
72
73
  }
@@ -83,22 +84,27 @@ function restoreNode(nodeList, ignoreBlock) {
83
84
  const below = text.slice(above.length + body.length);
84
85
  if (above) {
85
86
  const offset = node.startOffset + pointer;
86
- const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = utils_1.sliceFragment(source, offset, offset + above.length);
87
- const textNode = Object.assign(Object.assign({}, node), { uuid: utils_1.uuid(), type: ml_ast_1.MLASTNodeType.Text, raw,
87
+ const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = (0, get_location_1.sliceFragment)(source, offset, offset + above.length);
88
+ const textNode = {
89
+ ...node,
90
+ uuid: (0, create_token_1.uuid)(),
91
+ type: 'text',
92
+ raw,
88
93
  startOffset,
89
94
  endOffset,
90
95
  startLine,
91
96
  endLine,
92
97
  startCol,
93
- endCol });
98
+ endCol,
99
+ };
94
100
  insertList.push(textNode);
95
101
  }
96
102
  if (body) {
97
103
  const offset = node.startOffset + pointer + above.length;
98
- const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = utils_1.sliceFragment(source, offset, offset + body.length);
104
+ const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = (0, get_location_1.sliceFragment)(source, offset, offset + body.length);
99
105
  const bodyNode = {
100
- uuid: utils_1.uuid(),
101
- type: ml_ast_1.MLASTNodeType.PreprocessorSpecificBlock,
106
+ uuid: (0, create_token_1.uuid)(),
107
+ type: 'psblock',
102
108
  nodeName: `#ps:${tag.type}`,
103
109
  raw,
104
110
  parentNode: node.parentNode,
@@ -121,23 +127,28 @@ function restoreNode(nodeList, ignoreBlock) {
121
127
  }
122
128
  if (text) {
123
129
  const offset = node.endOffset - text.length;
124
- const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = utils_1.sliceFragment(source, offset, offset + text.length);
125
- const textNode = Object.assign(Object.assign({}, node), { uuid: utils_1.uuid(), type: ml_ast_1.MLASTNodeType.Text, raw,
130
+ const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = (0, get_location_1.sliceFragment)(source, offset, offset + text.length);
131
+ const textNode = {
132
+ ...node,
133
+ uuid: (0, create_token_1.uuid)(),
134
+ type: 'text',
135
+ raw,
126
136
  startOffset,
127
137
  endOffset,
128
138
  startLine,
129
139
  endLine,
130
140
  startCol,
131
- endCol });
141
+ endCol,
142
+ };
132
143
  insertList.push(textNode);
133
144
  }
134
- utils_1.siblingsCorrection(insertList);
145
+ (0, siblings_correction_1.siblingsCorrection)(insertList);
135
146
  if (parentNode) {
136
147
  parentNode.childNodes = insertList;
137
148
  }
138
149
  nodeList.splice(index, 1, ...insertList);
139
150
  }
140
- if (node.type === ml_ast_1.MLASTNodeType.StartTag) {
151
+ if (node.type === 'starttag') {
141
152
  for (const attr of node.attributes) {
142
153
  if (attr.type === 'ps-attr' || attr.value.raw === '' || !hasIgnoreBlock(attr.value.raw)) {
143
154
  continue;
@@ -0,0 +1 @@
1
+ export declare function ignoreFrontMatter(code: string): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ignoreFrontMatter = void 0;
4
+ function ignoreFrontMatter(code) {
5
+ const reStart = /^(?:\s*\r?\n)?---\r?\n/.exec(code);
6
+ if (!reStart) {
7
+ return code;
8
+ }
9
+ const startPoint = reStart[0].length;
10
+ const afterStart = code.slice(startPoint);
11
+ const reEnd = /\r?\n---\r?\n/.exec(afterStart);
12
+ if (!reEnd) {
13
+ return code;
14
+ }
15
+ const endPoint = startPoint + reEnd.index + reEnd[0].length;
16
+ const frontMatter = code.slice(0, endPoint);
17
+ const afterCode = code.slice(endPoint);
18
+ const masked = frontMatter.replace(/[^\r\n]/g, ' ');
19
+ return masked + afterCode;
20
+ }
21
+ exports.ignoreFrontMatter = ignoreFrontMatter;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ export * from './decision';
2
+ export * from './get-location';
3
+ export * from './create-token';
4
+ export * from './idl-attributes';
5
+ export * from './walker';
1
6
  export * from './ignore-block';
2
- export * from './utils';
3
- export declare function ignoreFrontMatter(code: string): string;
7
+ export * from './ignore-front-matter';
8
+ export * from './debugger';
package/lib/index.js CHANGED
@@ -1,24 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ignoreFrontMatter = void 0;
4
3
  const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./ignore-block"), exports);
6
- tslib_1.__exportStar(require("./utils"), exports);
7
- function ignoreFrontMatter(code) {
8
- const reStart = /^(?:\s*\r?\n)?---\r?\n/.exec(code);
9
- if (!reStart) {
10
- return code;
11
- }
12
- const startPoint = reStart[0].length;
13
- const afterStart = code.slice(startPoint);
14
- const reEnd = /\r?\n---\r?\n/.exec(afterStart);
15
- if (!reEnd) {
16
- return code;
17
- }
18
- const endPoint = startPoint + reEnd.index + reEnd[0].length;
19
- const frontMatter = code.slice(0, endPoint);
20
- const afterCode = code.slice(endPoint);
21
- const masked = frontMatter.replace(/[^\r\n]/g, ' ');
22
- return masked + afterCode;
23
- }
24
- exports.ignoreFrontMatter = ignoreFrontMatter;
4
+ (0, tslib_1.__exportStar)(require("./decision"), exports);
5
+ (0, tslib_1.__exportStar)(require("./get-location"), exports);
6
+ (0, tslib_1.__exportStar)(require("./create-token"), exports);
7
+ (0, tslib_1.__exportStar)(require("./idl-attributes"), exports);
8
+ (0, tslib_1.__exportStar)(require("./walker"), exports);
9
+ (0, tslib_1.__exportStar)(require("./ignore-block"), exports);
10
+ (0, tslib_1.__exportStar)(require("./ignore-front-matter"), exports);
11
+ (0, tslib_1.__exportStar)(require("./debugger"), exports);
@@ -0,0 +1,9 @@
1
+ import type { MLASTNode } from '@markuplint/ml-ast';
2
+ /**
3
+ * Correct the references to prevNode and nextNode in the order listed.
4
+ *
5
+ * @param nodeList
6
+ * @affects nodeList[].prevNode
7
+ * @affects nodeList[].nextNode
8
+ */
9
+ export declare function siblingsCorrection(nodeList: MLASTNode[]): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.siblingsCorrection = void 0;
4
+ /**
5
+ * Correct the references to prevNode and nextNode in the order listed.
6
+ *
7
+ * @param nodeList
8
+ * @affects nodeList[].prevNode
9
+ * @affects nodeList[].nextNode
10
+ */
11
+ function siblingsCorrection(nodeList) {
12
+ for (let i = 0; i < nodeList.length; i++) {
13
+ const prevNode = nodeList[i - 1] || null;
14
+ const node = nodeList[i];
15
+ const nextNode = nodeList[i + 1] || null;
16
+ node.prevNode = prevNode;
17
+ node.nextNode = nextNode;
18
+ }
19
+ }
20
+ exports.siblingsCorrection = siblingsCorrection;
@@ -0,0 +1,2 @@
1
+ import type { MLASTNode, Walker } from '@markuplint/ml-ast';
2
+ export declare function walk(nodeList: MLASTNode[], walker: Walker, depth?: number): void;