@markuplint/parser-utils 4.6.2 → 4.6.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.6.3](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.2...@markuplint/parser-utils@4.6.3) (2024-05-28)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **parser-utils:** correct length calculation for surrogate pairs in validScript ([37a712c](https://github.com/markuplint/markuplint/commit/37a712c2836bd701c680c1263669e105c0a8dea5))
11
+
6
12
  ## [4.6.2](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.1...@markuplint/parser-utils@4.6.2) (2024-05-12)
7
13
 
8
14
  **Note:** Version bump only for package @markuplint/parser-utils
@@ -129,7 +129,8 @@ export function attrTokenizer(raw, quoteSet = defaultQuoteSet, startState = Attr
129
129
  const raw = char + chars.join('');
130
130
  const { validScript } = safeScriptParser(raw, parser);
131
131
  attrValue += validScript;
132
- chars.splice(0, validScript.length - 1);
132
+ const length = [...validScript].length;
133
+ chars.splice(0, length - 1);
133
134
  break;
134
135
  }
135
136
  attrValue += char;
@@ -79,6 +79,7 @@ ignoreBlock, throwErrorWhenTagHasUnresolved = true) {
79
79
  parentNode: node.parentNode,
80
80
  childNodes: [],
81
81
  isBogus: false,
82
+ isFragment: false, // TODO: Case by case
82
83
  };
83
84
  replacementChildNodes.push(psNode);
84
85
  }
@@ -109,6 +110,7 @@ ignoreBlock, throwErrorWhenTagHasUnresolved = true) {
109
110
  parentNode: node.parentNode,
110
111
  childNodes: [],
111
112
  isBogus: false,
113
+ isFragment: false, // TODO: Case by case
112
114
  };
113
115
  replacementChildNodes.push(psNode);
114
116
  if (below) {
package/lib/parser.d.ts CHANGED
@@ -71,6 +71,7 @@ export declare abstract class Parser<Node extends {} = {}, State extends unknown
71
71
  }): readonly MLASTNodeTreeItem[];
72
72
  visitPsBlock(token: ChildToken & {
73
73
  readonly nodeName: string;
74
+ readonly isFragment: boolean;
74
75
  }, childNodes?: readonly Node[], conditionalType?: MLASTPreprocessorSpecificBlockConditionalType, originBlockNode?: Node): readonly MLASTNodeTreeItem[];
75
76
  visitChildren(children: readonly Node[], parentNode: MLASTParentNode | null): readonly MLASTNodeTreeItem[];
76
77
  visitSpreadAttr(token: Token): MLASTSpreadAttr | null;
package/lib/parser.js CHANGED
@@ -135,6 +135,7 @@ export class Parser {
135
135
  parentNode: null,
136
136
  raw,
137
137
  nodeName: 'front-matter',
138
+ isFragment: false,
138
139
  })[0];
139
140
  if (!fmNode) {
140
141
  throw new ParserError('Unexpected front matter', firstTextNode ?? token);
@@ -286,6 +287,7 @@ export class Parser {
286
287
  tagCloseChar: '',
287
288
  tagOpenChar: '',
288
289
  isGhost: true,
290
+ isFragment: false,
289
291
  ...overwriteProps,
290
292
  };
291
293
  const siblings = this.visitChildren(childNodes, startTag);
@@ -975,9 +977,10 @@ _Parser_booleanish = new WeakMap(), _Parser_defaultState = new WeakMap(), _Parse
975
977
  };
976
978
  }
977
979
  const tagToken = this.createToken(rawCodeFragment, tagStartOffset, tagStartLine, tagStartCol);
980
+ const isFragment = tagName === '';
978
981
  const commons = {
979
982
  depth,
980
- nodeName: tagName || '#jsx-fragment',
983
+ nodeName: isFragment ? '#jsx-fragment' : tagName,
981
984
  parentNode: null,
982
985
  };
983
986
  const tag = isOpenTag
@@ -994,6 +997,7 @@ _Parser_booleanish = new WeakMap(), _Parser_defaultState = new WeakMap(), _Parse
994
997
  tagCloseChar: selfClosingSolidusChar + '>',
995
998
  selfClosingSolidus,
996
999
  isGhost: false,
1000
+ isFragment,
997
1001
  }
998
1002
  : {
999
1003
  ...tagToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/parser-utils",
3
- "version": "4.6.2",
3
+ "version": "4.6.3",
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>",
@@ -27,17 +27,17 @@
27
27
  "clean": "tsc --build --clean"
28
28
  },
29
29
  "dependencies": {
30
- "@markuplint/ml-ast": "4.3.1",
31
- "@markuplint/ml-spec": "4.6.0",
32
- "@markuplint/types": "4.5.0",
30
+ "@markuplint/ml-ast": "4.4.0",
31
+ "@markuplint/ml-spec": "4.6.1",
32
+ "@markuplint/types": "4.5.1",
33
33
  "@types/uuid": "9.0.8",
34
34
  "debug": "4.3.4",
35
35
  "espree": "10.0.1",
36
- "type-fest": "4.18.2",
36
+ "type-fest": "4.18.3",
37
37
  "uuid": "9.0.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@typescript-eslint/typescript-estree": "7.8.0"
40
+ "@typescript-eslint/typescript-estree": "7.11.0"
41
41
  },
42
- "gitHead": "ca7dc6bf40eac4f2813e492878f889eb77751a70"
42
+ "gitHead": "bf70c41b1d2497e85b73c9ecd5551eb522e6bdfc"
43
43
  }