textlint-plugin-typst 1.1.0 → 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.
- package/lib/index.js +34 -10
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1727,14 +1727,15 @@ ${ctx.indent}`;
|
|
|
1727
1727
|
var require_log = __commonJS({
|
|
1728
1728
|
"node_modules/yaml/dist/log.js"(exports2) {
|
|
1729
1729
|
"use strict";
|
|
1730
|
+
var node_process = require("node:process");
|
|
1730
1731
|
function debug(logLevel, ...messages) {
|
|
1731
1732
|
if (logLevel === "debug")
|
|
1732
1733
|
console.log(...messages);
|
|
1733
1734
|
}
|
|
1734
1735
|
function warn(logLevel, warning) {
|
|
1735
1736
|
if (logLevel === "debug" || logLevel === "warn") {
|
|
1736
|
-
if (typeof
|
|
1737
|
-
|
|
1737
|
+
if (typeof node_process.emitWarning === "function")
|
|
1738
|
+
node_process.emitWarning(warning);
|
|
1738
1739
|
else
|
|
1739
1740
|
console.warn(warning);
|
|
1740
1741
|
}
|
|
@@ -2631,6 +2632,7 @@ var require_schema2 = __commonJS({
|
|
|
2631
2632
|
var require_binary = __commonJS({
|
|
2632
2633
|
"node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports2) {
|
|
2633
2634
|
"use strict";
|
|
2635
|
+
var node_buffer = require("node:buffer");
|
|
2634
2636
|
var Scalar = require_Scalar();
|
|
2635
2637
|
var stringifyString = require_stringifyString();
|
|
2636
2638
|
var binary = {
|
|
@@ -2647,8 +2649,8 @@ var require_binary = __commonJS({
|
|
|
2647
2649
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
2648
2650
|
*/
|
|
2649
2651
|
resolve(src, onError) {
|
|
2650
|
-
if (typeof Buffer === "function") {
|
|
2651
|
-
return Buffer.from(src, "base64");
|
|
2652
|
+
if (typeof node_buffer.Buffer === "function") {
|
|
2653
|
+
return node_buffer.Buffer.from(src, "base64");
|
|
2652
2654
|
} else if (typeof atob === "function") {
|
|
2653
2655
|
const str = atob(src.replace(/[\n\r]/g, ""));
|
|
2654
2656
|
const buffer = new Uint8Array(str.length);
|
|
@@ -2663,8 +2665,8 @@ var require_binary = __commonJS({
|
|
|
2663
2665
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
2664
2666
|
const buf = value;
|
|
2665
2667
|
let str;
|
|
2666
|
-
if (typeof Buffer === "function") {
|
|
2667
|
-
str = buf instanceof Buffer ? buf.toString("base64") : Buffer.from(buf.buffer).toString("base64");
|
|
2668
|
+
if (typeof node_buffer.Buffer === "function") {
|
|
2669
|
+
str = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
|
|
2668
2670
|
} else if (typeof btoa === "function") {
|
|
2669
2671
|
let s = "";
|
|
2670
2672
|
for (let i = 0; i < buf.length; ++i)
|
|
@@ -3862,7 +3864,7 @@ var require_resolve_props = __commonJS({
|
|
|
3862
3864
|
if (atNewline) {
|
|
3863
3865
|
if (comment)
|
|
3864
3866
|
comment += token.source;
|
|
3865
|
-
else
|
|
3867
|
+
else if (!found || indicator !== "seq-item-ind")
|
|
3866
3868
|
spaceBefore = true;
|
|
3867
3869
|
} else
|
|
3868
3870
|
commentSep += token.source;
|
|
@@ -5139,6 +5141,7 @@ var require_compose_doc = __commonJS({
|
|
|
5139
5141
|
var require_composer = __commonJS({
|
|
5140
5142
|
"node_modules/yaml/dist/compose/composer.js"(exports2) {
|
|
5141
5143
|
"use strict";
|
|
5144
|
+
var node_process = require("node:process");
|
|
5142
5145
|
var directives = require_directives();
|
|
5143
5146
|
var Document = require_Document();
|
|
5144
5147
|
var errors = require_errors();
|
|
@@ -5254,7 +5257,7 @@ ${cb}` : comment;
|
|
|
5254
5257
|
}
|
|
5255
5258
|
/** Advance the composer by one CST token. */
|
|
5256
5259
|
*next(token) {
|
|
5257
|
-
if (
|
|
5260
|
+
if (node_process.env.LOG_STREAM)
|
|
5258
5261
|
console.dir(token, { depth: null });
|
|
5259
5262
|
switch (token.type) {
|
|
5260
5263
|
case "directive":
|
|
@@ -6360,6 +6363,7 @@ var require_line_counter = __commonJS({
|
|
|
6360
6363
|
var require_parser = __commonJS({
|
|
6361
6364
|
"node_modules/yaml/dist/parse/parser.js"(exports2) {
|
|
6362
6365
|
"use strict";
|
|
6366
|
+
var node_process = require("node:process");
|
|
6363
6367
|
var cst = require_cst();
|
|
6364
6368
|
var lexer = require_lexer();
|
|
6365
6369
|
function includesToken(list, type) {
|
|
@@ -6483,7 +6487,7 @@ var require_parser = __commonJS({
|
|
|
6483
6487
|
*/
|
|
6484
6488
|
*next(source) {
|
|
6485
6489
|
this.source = source;
|
|
6486
|
-
if (
|
|
6490
|
+
if (node_process.env.LOG_TOKENS)
|
|
6487
6491
|
console.log("|", cst.prettyToken(source));
|
|
6488
6492
|
if (this.atScalar) {
|
|
6489
6493
|
this.atScalar = false;
|
|
@@ -7879,6 +7883,9 @@ var convertRawTypstAstStringToObject = (rawTypstAstString) => {
|
|
|
7879
7883
|
removeFirstLine(rawTypstAstString)
|
|
7880
7884
|
);
|
|
7881
7885
|
const parsed = (0, import_yaml.parse)(escapedRawTypstAstYamlString);
|
|
7886
|
+
if (parsed.ast.c === null) {
|
|
7887
|
+
parsed.ast.c = [];
|
|
7888
|
+
}
|
|
7882
7889
|
return parsed.ast;
|
|
7883
7890
|
};
|
|
7884
7891
|
var extractRawSourceByLocation = (typstSource, location) => {
|
|
@@ -7928,6 +7935,12 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
|
|
|
7928
7935
|
const match = s.match(/<(\d+:\d+)~(\d+:\d+)>/);
|
|
7929
7936
|
if (!match) {
|
|
7930
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
|
+
}
|
|
7931
7944
|
const rootChildrenStartLocation = extractLocation(c[0].s, c[0].c);
|
|
7932
7945
|
const rootChildrenEndLocation = extractLocation(
|
|
7933
7946
|
c[c.length - 1].s,
|
|
@@ -7952,7 +7965,7 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
|
|
|
7952
7965
|
const location = extractLocation(node.s, node.c);
|
|
7953
7966
|
const nodeRawText = extractRawSourceByLocation(typstSource, location);
|
|
7954
7967
|
const nodeLength = nodeRawText.length;
|
|
7955
|
-
if (node.c
|
|
7968
|
+
if (node.c) {
|
|
7956
7969
|
let childOffset = startOffset;
|
|
7957
7970
|
const whitespaceNodes = [];
|
|
7958
7971
|
const softBreakNodes = [];
|
|
@@ -8077,6 +8090,17 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
|
|
|
8077
8090
|
delete node.c;
|
|
8078
8091
|
return endOffset;
|
|
8079
8092
|
};
|
|
8093
|
+
if (textlintAstObject.c && textlintAstObject.c.length > 0) {
|
|
8094
|
+
const rootChildrenStartLocation = extractLocation(
|
|
8095
|
+
textlintAstObject.c[0].s,
|
|
8096
|
+
textlintAstObject.c[0].c
|
|
8097
|
+
);
|
|
8098
|
+
if (rootChildrenStartLocation.start.line === 2) {
|
|
8099
|
+
textlintAstObject.c.unshift({
|
|
8100
|
+
s: "<span style='color:#7dcfff'>Marked::Parbreak</span> <1:0~2:0>"
|
|
8101
|
+
});
|
|
8102
|
+
}
|
|
8103
|
+
}
|
|
8080
8104
|
calculateOffsets(textlintAstObject);
|
|
8081
8105
|
textlintAstObject.type = import_ast_node_types.ASTNodeTypes.Document;
|
|
8082
8106
|
return textlintAstObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textlint-plugin-typst",
|
|
3
|
-
"version": "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",
|