@markuplint/parser-utils 3.3.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 CHANGED
@@ -1,4 +1,4 @@
1
- export declare const MASK_CHAR = "\uE000";
1
+ export declare const MASK_CHAR = '\uE000';
2
2
  /**
3
3
  * SVG Element list
4
4
  *
@@ -1,4 +1,9 @@
1
1
  import type { MLToken } from '@markuplint/ml-ast';
2
- export declare function tokenizer(raw: string | null, startLine: number, startCol: number, startOffset: number): MLToken;
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(name: string, option?: ParserAuthoredElementNameDistinguishing, defaultPattern?: ParserAuthoredElementNameDistinguishing): ElementType;
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);
@@ -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(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;
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
  };
@@ -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) {
@@ -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
  };
@@ -109,9 +109,8 @@ const idlContentMap = {
109
109
  placeholder: 'placeholder',
110
110
  playsInline: 'playsinline',
111
111
  popover: 'popover',
112
- popoverHideTarget: 'popoverhidetarget',
113
- popoverShowTarget: 'popovershowtarget',
114
- popoverToggleTarget: 'popovertoggletarget',
112
+ popoverTarget: 'popovertarget',
113
+ popoverTargetAction: 'popovertargetaction',
115
114
  poster: 'poster',
116
115
  preload: 'preload',
117
116
  profile: 'profile',
@@ -433,7 +432,7 @@ function searchIDLAttribute(name) {
433
432
  }
434
433
  exports.searchIDLAttribute = searchIDLAttribute;
435
434
  function camelize(str) {
436
- 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 : ''; });
437
436
  }
438
437
  function hyphenize(str) {
439
438
  return str.replace(/[A-Z]/g, $0 => `-${$0.toLowerCase()}`);
@@ -1,13 +1,21 @@
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(message: string, { line, col, raw, nodeName, }: {
8
- line?: number;
9
- col?: number;
10
- raw?: string;
11
- nodeName?: string | null;
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
- type: string;
3
- index: number;
4
- startTag: string;
5
- taggedCode: string;
6
- endTag: string | null;
2
+ type: string;
3
+ index: number;
4
+ startTag: string;
5
+ taggedCode: string;
6
+ endTag: string | null;
7
7
  };
8
8
  export type IgnoreTag = {
9
- type: string;
10
- start: RegExp;
11
- end: RegExp;
9
+ type: string;
10
+ start: RegExp;
11
+ end: RegExp;
12
12
  };
13
13
  export type IgnoreBlock = {
14
- source: string;
15
- replaced: string;
16
- stack: Code[];
17
- maskChar: string;
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.0",
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>",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@markuplint/ml-ast": "3.0.0",
26
- "@markuplint/types": "3.2.0",
26
+ "@markuplint/types": "3.3.0",
27
27
  "tslib": "^2.4.1",
28
28
  "uuid": "^9.0.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@markuplint/ml-core": "3.x"
32
32
  },
33
- "gitHead": "791fb22a4df7acb985ced3808923fba0cd95c28a"
33
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
34
34
  }