textlint-plugin-typst 1.1.1 → 1.1.2

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.
Files changed (2) hide show
  1. package/lib/index.js +11 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -7883,6 +7883,9 @@ var convertRawTypstAstStringToObject = (rawTypstAstString) => {
7883
7883
  removeFirstLine(rawTypstAstString)
7884
7884
  );
7885
7885
  const parsed = (0, import_yaml.parse)(escapedRawTypstAstYamlString);
7886
+ if (parsed.ast.c === null) {
7887
+ parsed.ast.c = [];
7888
+ }
7886
7889
  return parsed.ast;
7887
7890
  };
7888
7891
  var extractRawSourceByLocation = (typstSource, location) => {
@@ -7932,6 +7935,12 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
7932
7935
  const match = s.match(/<(\d+:\d+)~(\d+:\d+)>/);
7933
7936
  if (!match) {
7934
7937
  if (c !== void 0) {
7938
+ if (c.length === 0) {
7939
+ return {
7940
+ start: { line: 1, column: 0 },
7941
+ end: { line: 1, column: 0 }
7942
+ };
7943
+ }
7935
7944
  const rootChildrenStartLocation = extractLocation(c[0].s, c[0].c);
7936
7945
  const rootChildrenEndLocation = extractLocation(
7937
7946
  c[c.length - 1].s,
@@ -7956,7 +7965,7 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
7956
7965
  const location = extractLocation(node.s, node.c);
7957
7966
  const nodeRawText = extractRawSourceByLocation(typstSource, location);
7958
7967
  const nodeLength = nodeRawText.length;
7959
- if (node.c && node.c.length > 0) {
7968
+ if (node.c) {
7960
7969
  let childOffset = startOffset;
7961
7970
  const whitespaceNodes = [];
7962
7971
  const softBreakNodes = [];
@@ -8081,7 +8090,7 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
8081
8090
  delete node.c;
8082
8091
  return endOffset;
8083
8092
  };
8084
- if (textlintAstObject.c) {
8093
+ if (textlintAstObject.c && textlintAstObject.c.length > 0) {
8085
8094
  const rootChildrenStartLocation = extractLocation(
8086
8095
  textlintAstObject.c[0].s,
8087
8096
  textlintAstObject.c[0].c
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "textlint-plugin-typst",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "textlint plugin to lint Typst",
5
5
  "keywords": ["textlint", "textlintplugin", "plugin", "lint", "typst"],
6
6
  "repository": "https://github.com/3w36zj6/textlint-plugin-typst",