@markuplint/astro-parser 3.3.1 → 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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.attrTokenizer = void 0;
4
4
  const parser_utils_1 = require("@markuplint/parser-utils");
5
5
  function attrTokenizer(attr, rawHtml, codeOffset) {
6
- var _a, _b, _c, _d, _e, _f;
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
7
7
  const { raw, startOffset } = (0, parser_utils_1.sliceFragment)(rawHtml, attr.start + codeOffset, attr.end + codeOffset);
8
8
  const isDynamicValue = ((_b = (_a = attr.value) === null || _a === void 0 ? void 0 : _a.some) === null || _b === void 0 ? void 0 : _b.call(_a, v => {
9
9
  // @ts-ignore
@@ -28,21 +28,21 @@ function attrTokenizer(attr, rawHtml, codeOffset) {
28
28
  rawValueStart = name.endOffset;
29
29
  }
30
30
  else if (isDynamicValue) {
31
- rawValue = attr.value[0].expression.codeChunks.join('');
32
- rawValueStart = attr.value[0].expression.start;
31
+ rawValue = (_d = (_c = attr.value[0]) === null || _c === void 0 ? void 0 : _c.expression.codeChunks.join('')) !== null && _d !== void 0 ? _d : '';
32
+ rawValueStart = (_f = (_e = attr.value[0]) === null || _e === void 0 ? void 0 : _e.expression.start) !== null && _f !== void 0 ? _f : name.endOffset;
33
33
  }
34
34
  else {
35
- rawValue = attr.value[0].raw;
36
- rawValueStart = attr.value[0].start;
35
+ rawValue = (_h = (_g = attr.value[0]) === null || _g === void 0 ? void 0 : _g.raw) !== null && _h !== void 0 ? _h : '';
36
+ rawValueStart = (_k = (_j = attr.value[0]) === null || _j === void 0 ? void 0 : _j.start) !== null && _k !== void 0 ? _k : name.endOffset;
37
37
  }
38
38
  const value = (0, parser_utils_1.createTokenFromRawCode)(rawValue, rawValueStart + codeOffset, rawHtml);
39
39
  const eq = (0, parser_utils_1.sliceFragment)(rawHtml, name.endOffset, value.startOffset);
40
40
  const eqRegexp = /^(?<bs>\s*)(?<eq>=)(?<as>\s*)(?<squot>"|'|{)?$/g;
41
41
  const exp = eqRegexp.exec(eq.raw);
42
- const bsChar = ((_c = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _c === void 0 ? void 0 : _c.bs) || '';
43
- const eqChar = ((_d = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _d === void 0 ? void 0 : _d.eq) || '';
44
- const asChar = ((_e = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _e === void 0 ? void 0 : _e.as) || '';
45
- const squotChar = ((_f = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _f === void 0 ? void 0 : _f.squot) || '';
42
+ const bsChar = ((_l = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _l === void 0 ? void 0 : _l.bs) || '';
43
+ const eqChar = ((_m = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _m === void 0 ? void 0 : _m.eq) || '';
44
+ const asChar = ((_o = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _o === void 0 ? void 0 : _o.as) || '';
45
+ const squotChar = ((_p = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _p === void 0 ? void 0 : _p.squot) || '';
46
46
  const spacesBeforeEqual = (0, parser_utils_1.createTokenFromRawCode)(bsChar, name.endOffset, rawHtml);
47
47
  const equal = (0, parser_utils_1.createTokenFromRawCode)(eqChar, spacesBeforeEqual.endOffset, rawHtml);
48
48
  const spacesAfterEqual = (0, parser_utils_1.createTokenFromRawCode)(asChar, equal.endOffset, rawHtml);
package/lib/parse.js CHANGED
@@ -31,7 +31,7 @@ const parse = (rawCode, options) => {
31
31
  if (templateEndTagIndex !== -1) {
32
32
  const templateEndTag = nodeList[templateEndTagIndex];
33
33
  for (const node of nodeList) {
34
- if (node.nextNode && node.nextNode.uuid === templateEndTag.uuid) {
34
+ if (node.nextNode && node.nextNode.uuid === (templateEndTag === null || templateEndTag === void 0 ? void 0 : templateEndTag.uuid)) {
35
35
  node.nextNode = null;
36
36
  }
37
37
  }
@@ -223,12 +223,13 @@ function nodeize(originNode, prevNode, parentNode, scopeNS, rawHtml, offset = 0,
223
223
  }
224
224
  }
225
225
  function parseElement(nodeName, originNode, scopeNS, rawHtml, startLine, startCol, startOffset, parentNode, prevNode, nextNode, offset, options) {
226
+ var _a, _b;
226
227
  const { raw } = (0, parser_utils_1.sliceFragment)(rawHtml, originNode.start + offset, originNode.end + offset);
227
228
  let childrenStart;
228
229
  let childrenEnd;
229
230
  if (originNode.children && originNode.children[0]) {
230
231
  childrenStart = originNode.children[0].start + offset;
231
- childrenEnd = originNode.children[originNode.children.length - 1].end + offset;
232
+ childrenEnd = ((_b = (_a = originNode.children[originNode.children.length - 1]) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : 0) + offset;
232
233
  }
233
234
  else if (originNode.content) {
234
235
  childrenStart = originNode.content.start + offset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/astro-parser",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "description": "astro parser for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@astrojs/parser": "0.20",
20
- "@markuplint/html-parser": "3.3.1",
20
+ "@markuplint/html-parser": "3.4.0",
21
21
  "@markuplint/ml-ast": "3.0.0",
22
- "@markuplint/parser-utils": "3.3.0",
22
+ "@markuplint/parser-utils": "3.4.0",
23
23
  "tslib": "^2.4.1"
24
24
  },
25
- "gitHead": "f19e7de726cf01d53342bc5513c30da75d28da63"
25
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
26
26
  }