textlint-plugin-typst 1.0.1 → 1.1.1
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/README.md +1 -1
- package/lib/index.js +61 -29
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ bun add textlint-plugin-typst
|
|
|
40
40
|
|
|
41
41
|
## Syntax support
|
|
42
42
|
|
|
43
|
-
This plugin supports the syntax of Typst [v0.
|
|
43
|
+
This plugin supports the syntax of Typst [v0.12.0](https://github.com/typst/typst/releases/tag/v0.12.0).
|
|
44
44
|
|
|
45
45
|
Legend for syntax support:
|
|
46
46
|
|
package/lib/index.js
CHANGED
|
@@ -1375,21 +1375,29 @@ ${indent}`) + "'";
|
|
|
1375
1375
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
1376
1376
|
}
|
|
1377
1377
|
const indentSize = indent ? "2" : "1";
|
|
1378
|
-
let header = (
|
|
1378
|
+
let header = (startWithSpace ? indentSize : "") + chomp;
|
|
1379
1379
|
if (comment) {
|
|
1380
1380
|
header += " " + commentString(comment.replace(/ ?[\r\n]+/g, " "));
|
|
1381
1381
|
if (onComment)
|
|
1382
1382
|
onComment();
|
|
1383
1383
|
}
|
|
1384
|
-
if (literal) {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1384
|
+
if (!literal) {
|
|
1385
|
+
const foldedValue = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`);
|
|
1386
|
+
let literalFallback = false;
|
|
1387
|
+
const foldOptions = getFoldOptions(ctx, true);
|
|
1388
|
+
if (blockQuote !== "folded" && type !== Scalar.Scalar.BLOCK_FOLDED) {
|
|
1389
|
+
foldOptions.onOverflow = () => {
|
|
1390
|
+
literalFallback = true;
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
const body = foldFlowLines.foldFlowLines(`${start}${foldedValue}${end}`, indent, foldFlowLines.FOLD_BLOCK, foldOptions);
|
|
1394
|
+
if (!literalFallback)
|
|
1395
|
+
return `>${header}
|
|
1392
1396
|
${indent}${body}`;
|
|
1397
|
+
}
|
|
1398
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
1399
|
+
return `|${header}
|
|
1400
|
+
${indent}${start}${value}${end}`;
|
|
1393
1401
|
}
|
|
1394
1402
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
1395
1403
|
const { type, value } = item;
|
|
@@ -1719,14 +1727,15 @@ ${ctx.indent}`;
|
|
|
1719
1727
|
var require_log = __commonJS({
|
|
1720
1728
|
"node_modules/yaml/dist/log.js"(exports2) {
|
|
1721
1729
|
"use strict";
|
|
1730
|
+
var node_process = require("node:process");
|
|
1722
1731
|
function debug(logLevel, ...messages) {
|
|
1723
1732
|
if (logLevel === "debug")
|
|
1724
1733
|
console.log(...messages);
|
|
1725
1734
|
}
|
|
1726
1735
|
function warn(logLevel, warning) {
|
|
1727
1736
|
if (logLevel === "debug" || logLevel === "warn") {
|
|
1728
|
-
if (typeof
|
|
1729
|
-
|
|
1737
|
+
if (typeof node_process.emitWarning === "function")
|
|
1738
|
+
node_process.emitWarning(warning);
|
|
1730
1739
|
else
|
|
1731
1740
|
console.warn(warning);
|
|
1732
1741
|
}
|
|
@@ -2584,7 +2593,7 @@ var require_schema2 = __commonJS({
|
|
|
2584
2593
|
identify: (value) => typeof value === "boolean",
|
|
2585
2594
|
default: true,
|
|
2586
2595
|
tag: "tag:yaml.org,2002:bool",
|
|
2587
|
-
test: /^true
|
|
2596
|
+
test: /^true$|^false$/,
|
|
2588
2597
|
resolve: (str) => str === "true",
|
|
2589
2598
|
stringify: stringifyJSON
|
|
2590
2599
|
},
|
|
@@ -2623,6 +2632,7 @@ var require_schema2 = __commonJS({
|
|
|
2623
2632
|
var require_binary = __commonJS({
|
|
2624
2633
|
"node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports2) {
|
|
2625
2634
|
"use strict";
|
|
2635
|
+
var node_buffer = require("node:buffer");
|
|
2626
2636
|
var Scalar = require_Scalar();
|
|
2627
2637
|
var stringifyString = require_stringifyString();
|
|
2628
2638
|
var binary = {
|
|
@@ -2639,8 +2649,8 @@ var require_binary = __commonJS({
|
|
|
2639
2649
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
2640
2650
|
*/
|
|
2641
2651
|
resolve(src, onError) {
|
|
2642
|
-
if (typeof Buffer === "function") {
|
|
2643
|
-
return Buffer.from(src, "base64");
|
|
2652
|
+
if (typeof node_buffer.Buffer === "function") {
|
|
2653
|
+
return node_buffer.Buffer.from(src, "base64");
|
|
2644
2654
|
} else if (typeof atob === "function") {
|
|
2645
2655
|
const str = atob(src.replace(/[\n\r]/g, ""));
|
|
2646
2656
|
const buffer = new Uint8Array(str.length);
|
|
@@ -2655,8 +2665,8 @@ var require_binary = __commonJS({
|
|
|
2655
2665
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
2656
2666
|
const buf = value;
|
|
2657
2667
|
let str;
|
|
2658
|
-
if (typeof Buffer === "function") {
|
|
2659
|
-
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");
|
|
2660
2670
|
} else if (typeof btoa === "function") {
|
|
2661
2671
|
let s = "";
|
|
2662
2672
|
for (let i = 0; i < buf.length; ++i)
|
|
@@ -3168,7 +3178,7 @@ var require_timestamp = __commonJS({
|
|
|
3168
3178
|
}
|
|
3169
3179
|
return new Date(date);
|
|
3170
3180
|
},
|
|
3171
|
-
stringify: ({ value }) => value.toISOString().replace(/(
|
|
3181
|
+
stringify: ({ value }) => value.toISOString().replace(/(T00:00:00)?\.000Z$/, "")
|
|
3172
3182
|
};
|
|
3173
3183
|
exports2.floatTime = floatTime;
|
|
3174
3184
|
exports2.intTime = intTime;
|
|
@@ -3854,7 +3864,7 @@ var require_resolve_props = __commonJS({
|
|
|
3854
3864
|
if (atNewline) {
|
|
3855
3865
|
if (comment)
|
|
3856
3866
|
comment += token.source;
|
|
3857
|
-
else
|
|
3867
|
+
else if (!found || indicator !== "seq-item-ind")
|
|
3858
3868
|
spaceBefore = true;
|
|
3859
3869
|
} else
|
|
3860
3870
|
commentSep += token.source;
|
|
@@ -5131,6 +5141,7 @@ var require_compose_doc = __commonJS({
|
|
|
5131
5141
|
var require_composer = __commonJS({
|
|
5132
5142
|
"node_modules/yaml/dist/compose/composer.js"(exports2) {
|
|
5133
5143
|
"use strict";
|
|
5144
|
+
var node_process = require("node:process");
|
|
5134
5145
|
var directives = require_directives();
|
|
5135
5146
|
var Document = require_Document();
|
|
5136
5147
|
var errors = require_errors();
|
|
@@ -5246,7 +5257,7 @@ ${cb}` : comment;
|
|
|
5246
5257
|
}
|
|
5247
5258
|
/** Advance the composer by one CST token. */
|
|
5248
5259
|
*next(token) {
|
|
5249
|
-
if (
|
|
5260
|
+
if (node_process.env.LOG_STREAM)
|
|
5250
5261
|
console.dir(token, { depth: null });
|
|
5251
5262
|
switch (token.type) {
|
|
5252
5263
|
case "directive":
|
|
@@ -6352,6 +6363,7 @@ var require_line_counter = __commonJS({
|
|
|
6352
6363
|
var require_parser = __commonJS({
|
|
6353
6364
|
"node_modules/yaml/dist/parse/parser.js"(exports2) {
|
|
6354
6365
|
"use strict";
|
|
6366
|
+
var node_process = require("node:process");
|
|
6355
6367
|
var cst = require_cst();
|
|
6356
6368
|
var lexer = require_lexer();
|
|
6357
6369
|
function includesToken(list, type) {
|
|
@@ -6475,7 +6487,7 @@ var require_parser = __commonJS({
|
|
|
6475
6487
|
*/
|
|
6476
6488
|
*next(source) {
|
|
6477
6489
|
this.source = source;
|
|
6478
|
-
if (
|
|
6490
|
+
if (node_process.env.LOG_TOKENS)
|
|
6479
6491
|
console.log("|", cst.prettyToken(source));
|
|
6480
6492
|
if (this.atScalar) {
|
|
6481
6493
|
this.atScalar = false;
|
|
@@ -7540,16 +7552,14 @@ replaceTraps((oldTraps) => ({
|
|
|
7540
7552
|
|
|
7541
7553
|
// node_modules/@myriaddreamin/typst.ts/dist/esm/init.mjs
|
|
7542
7554
|
var ComponentBuilder = class {
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
this.fetcher = fetch;
|
|
7546
|
-
}
|
|
7555
|
+
loadedFonts = /* @__PURE__ */ new Set();
|
|
7556
|
+
fetcher = fetch;
|
|
7547
7557
|
setFetcher(fetcher) {
|
|
7548
7558
|
this.fetcher = fetcher;
|
|
7549
7559
|
}
|
|
7550
7560
|
async loadFonts(builder, fonts) {
|
|
7551
7561
|
const escapeImport = new Function("m", "return import(m)");
|
|
7552
|
-
const fetcher = this.fetcher
|
|
7562
|
+
const fetcher = this.fetcher ||= await async function() {
|
|
7553
7563
|
const { fetchBuilder, FileSystemCache } = await escapeImport("node-fetch-cache");
|
|
7554
7564
|
const cache = new FileSystemCache({
|
|
7555
7565
|
/// By default, we don't have a complicated cache policy.
|
|
@@ -7564,7 +7574,7 @@ var ComponentBuilder = class {
|
|
|
7564
7574
|
clearTimeout(timeout);
|
|
7565
7575
|
});
|
|
7566
7576
|
};
|
|
7567
|
-
}()
|
|
7577
|
+
}();
|
|
7568
7578
|
const fontsToLoad = fonts.filter((font) => {
|
|
7569
7579
|
if (font instanceof Uint8Array) {
|
|
7570
7580
|
return true;
|
|
@@ -7685,6 +7695,8 @@ var once = (fn) => {
|
|
|
7685
7695
|
};
|
|
7686
7696
|
};
|
|
7687
7697
|
var LazyWasmModule = class {
|
|
7698
|
+
wasmBin;
|
|
7699
|
+
initOnce;
|
|
7688
7700
|
constructor(initFn) {
|
|
7689
7701
|
if (typeof initFn !== "function") {
|
|
7690
7702
|
throw new Error("initFn is not a function");
|
|
@@ -7701,6 +7713,10 @@ var LazyWasmModule = class {
|
|
|
7701
7713
|
|
|
7702
7714
|
// node_modules/@myriaddreamin/typst.ts/dist/esm/compiler.mjs
|
|
7703
7715
|
var IncrementalServer = class {
|
|
7716
|
+
/**
|
|
7717
|
+
* @internal
|
|
7718
|
+
*/
|
|
7719
|
+
[kObject];
|
|
7704
7720
|
/**
|
|
7705
7721
|
* @internal
|
|
7706
7722
|
*/
|
|
@@ -7734,6 +7750,8 @@ function createTypstCompiler() {
|
|
|
7734
7750
|
return new TypstCompilerDriver();
|
|
7735
7751
|
}
|
|
7736
7752
|
var TypstCompilerDriver = class {
|
|
7753
|
+
compiler;
|
|
7754
|
+
compilerJs;
|
|
7737
7755
|
constructor() {
|
|
7738
7756
|
}
|
|
7739
7757
|
async init(options) {
|
|
@@ -7753,15 +7771,15 @@ var TypstCompilerDriver = class {
|
|
|
7753
7771
|
compile(options) {
|
|
7754
7772
|
return new Promise((resolve) => {
|
|
7755
7773
|
if ("incrementalServer" in options) {
|
|
7756
|
-
resolve(this.compiler.incr_compile(options.mainFilePath, options.incrementalServer[kObject], getDiagnosticsArg(options.diagnostics)));
|
|
7774
|
+
resolve(this.compiler.incr_compile(options.mainFilePath, convertInputs(options.inputs), options.incrementalServer[kObject], getDiagnosticsArg(options.diagnostics)));
|
|
7757
7775
|
return;
|
|
7758
7776
|
}
|
|
7759
|
-
resolve(this.compiler.compile(options.mainFilePath, options.format || "vector", getDiagnosticsArg(options.diagnostics)));
|
|
7777
|
+
resolve(this.compiler.compile(options.mainFilePath, convertInputs(options.inputs), options.format || "vector", getDiagnosticsArg(options.diagnostics)));
|
|
7760
7778
|
});
|
|
7761
7779
|
}
|
|
7762
7780
|
query(options) {
|
|
7763
7781
|
return new Promise((resolve) => {
|
|
7764
|
-
resolve(JSON.parse(this.compiler.query(options.mainFilePath, options.selector, options.field)));
|
|
7782
|
+
resolve(JSON.parse(this.compiler.query(options.mainFilePath, convertInputs(options.inputs), options.selector, options.field)));
|
|
7765
7783
|
});
|
|
7766
7784
|
}
|
|
7767
7785
|
getSemanticTokenLegend() {
|
|
@@ -7811,6 +7829,9 @@ var TypstCompilerDriver = class {
|
|
|
7811
7829
|
throw new Error("Please use the api TypstRenderer.renderToCanvas in v0.4.0");
|
|
7812
7830
|
}
|
|
7813
7831
|
};
|
|
7832
|
+
function convertInputs(inputs) {
|
|
7833
|
+
return inputs ? Object.entries(inputs) : void 0;
|
|
7834
|
+
}
|
|
7814
7835
|
function getDiagnosticsArg(diagnostics) {
|
|
7815
7836
|
switch (diagnostics) {
|
|
7816
7837
|
case "none":
|
|
@@ -8060,6 +8081,17 @@ var convertRawTypstAstObjectToTextlintAstObject = (rawTypstAstObject, typstSourc
|
|
|
8060
8081
|
delete node.c;
|
|
8061
8082
|
return endOffset;
|
|
8062
8083
|
};
|
|
8084
|
+
if (textlintAstObject.c) {
|
|
8085
|
+
const rootChildrenStartLocation = extractLocation(
|
|
8086
|
+
textlintAstObject.c[0].s,
|
|
8087
|
+
textlintAstObject.c[0].c
|
|
8088
|
+
);
|
|
8089
|
+
if (rootChildrenStartLocation.start.line === 2) {
|
|
8090
|
+
textlintAstObject.c.unshift({
|
|
8091
|
+
s: "<span style='color:#7dcfff'>Marked::Parbreak</span> <1:0~2:0>"
|
|
8092
|
+
});
|
|
8093
|
+
}
|
|
8094
|
+
}
|
|
8063
8095
|
calculateOffsets(textlintAstObject);
|
|
8064
8096
|
textlintAstObject.type = import_ast_node_types.ASTNodeTypes.Document;
|
|
8065
8097
|
return textlintAstObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textlint-plugin-typst",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"update-fixtures": "bun ./test/update-fixtures.ts && biome check --write ./test/fixtures"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@myriaddreamin/typst-ts-web-compiler": "^0.5.
|
|
29
|
-
"@myriaddreamin/typst.ts": "^0.5.
|
|
28
|
+
"@myriaddreamin/typst-ts-web-compiler": "^0.5.1",
|
|
29
|
+
"@myriaddreamin/typst.ts": "^0.5.1",
|
|
30
30
|
"yaml": "^2.5.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|