@gmb/bitmark-parser 6.3.0 → 6.3.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 +40 -10
- package/dist/browser/bitmark-parser.min.js +4 -4
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +34 -12
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +11 -2
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +11 -2
- package/dist/browser/esm/index.js +34 -12
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/index.cjs +34 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +34 -12
- package/dist/index.js.map +1 -1
- package/dist/legacy.cjs +34 -12
- package/dist/legacy.cjs.map +1 -1
- package/dist/legacy.d.cts +11 -2
- package/dist/legacy.d.ts +11 -2
- package/dist/legacy.js +34 -12
- package/dist/legacy.js.map +1 -1
- package/package.json +6 -6
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -58,7 +58,7 @@ var import_node_module = require("module");
|
|
|
58
58
|
// src/generated/package_info.ts
|
|
59
59
|
var PACKAGE_INFO = {
|
|
60
60
|
"name": "@gmb/bitmark-parser",
|
|
61
|
-
"version": "6.3.
|
|
61
|
+
"version": "6.3.1",
|
|
62
62
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
63
63
|
"license": "ISC",
|
|
64
64
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -427,6 +427,13 @@ var DEPRECATED_TEXT_FORMATS = {
|
|
|
427
427
|
"bitmark--": "bitmark++",
|
|
428
428
|
"bitmark+": "bitmark++"
|
|
429
429
|
};
|
|
430
|
+
var CONFIG_BODY_FORMAT_TO_TEXT_FORMAT = {
|
|
431
|
+
bitmark: "bitmark++",
|
|
432
|
+
text: "text",
|
|
433
|
+
json: "json",
|
|
434
|
+
latex: "latex",
|
|
435
|
+
xml: "xml"
|
|
436
|
+
};
|
|
430
437
|
var TAG_TEXT_KEYS = [
|
|
431
438
|
"title",
|
|
432
439
|
"subtitle",
|
|
@@ -472,7 +479,7 @@ var Builder = class {
|
|
|
472
479
|
const wasm2 = getLegacyWasm();
|
|
473
480
|
const src = { ...data };
|
|
474
481
|
const bitType = src.bitType;
|
|
475
|
-
this.
|
|
482
|
+
const bitConfig = this.getBitConfig(bitType);
|
|
476
483
|
const bit = {};
|
|
477
484
|
bit.type = bitType;
|
|
478
485
|
if (src.isCommented) {
|
|
@@ -485,6 +492,8 @@ var Builder = class {
|
|
|
485
492
|
if (textFormat !== void 0) {
|
|
486
493
|
bit.format = DEPRECATED_TEXT_FORMATS[textFormat] ?? textFormat;
|
|
487
494
|
delete src.textFormat;
|
|
495
|
+
} else {
|
|
496
|
+
bit.format = CONFIG_BODY_FORMAT_TO_TEXT_FORMAT[bitConfig.bodyFormat ?? ""] ?? "bitmark++";
|
|
488
497
|
}
|
|
489
498
|
delete src.resourceType;
|
|
490
499
|
const body = src.body;
|
|
@@ -576,6 +585,12 @@ var Builder = class {
|
|
|
576
585
|
* (inline marks become TextAst marks); the composer would otherwise treat
|
|
577
586
|
* them as literal text. Converts top-level JsonText fields in place.
|
|
578
587
|
* Nested (card-content) strings are left literal — documented divergence.
|
|
588
|
+
*
|
|
589
|
+
* A string body is dispatched on the bit's resolved text format, as bpg's
|
|
590
|
+
* buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
|
|
591
|
+
* (unparseable → null), and plain-text formats (text/latex/xml) stay
|
|
592
|
+
* verbatim. Tag texts are always bitmark text, independent of body format
|
|
593
|
+
* (bpg TextParser.toAst ignores format; only location matters).
|
|
579
594
|
*/
|
|
580
595
|
parseStringTexts(bit) {
|
|
581
596
|
const wasm2 = getLegacyWasm();
|
|
@@ -590,29 +605,36 @@ var Builder = class {
|
|
|
590
605
|
};
|
|
591
606
|
const format = bit.format;
|
|
592
607
|
const bitmarkBody = format === void 0 || format === "bitmark++" || format === "bitmark+";
|
|
593
|
-
if (typeof bit.body === "string"
|
|
594
|
-
|
|
608
|
+
if (typeof bit.body === "string") {
|
|
609
|
+
if (format === "json") {
|
|
610
|
+
try {
|
|
611
|
+
bit.body = JSON.parse(bit.body);
|
|
612
|
+
} catch {
|
|
613
|
+
bit.body = null;
|
|
614
|
+
}
|
|
615
|
+
} else if (bitmarkBody) {
|
|
616
|
+
bit.body = toAst(bit.body, "body");
|
|
617
|
+
}
|
|
595
618
|
}
|
|
596
619
|
for (const key of TAG_TEXT_KEYS) {
|
|
597
620
|
const v = bit[key];
|
|
598
621
|
if (typeof v === "string") bit[key] = toAst(v, "tag");
|
|
599
622
|
}
|
|
600
623
|
}
|
|
601
|
-
/**
|
|
602
|
-
|
|
624
|
+
/**
|
|
625
|
+
* Look up the bit's config (`wasm.info`); throws bpg's exact
|
|
626
|
+
* unknown-bit-type error (`Config.getBitConfig` parity).
|
|
627
|
+
*/
|
|
628
|
+
getBitConfig(bitType) {
|
|
603
629
|
const wasm2 = getLegacyWasm();
|
|
604
|
-
let known = false;
|
|
605
630
|
if (bitType !== void 0) {
|
|
606
631
|
try {
|
|
607
632
|
const info2 = JSON.parse(wasm2.info("bit", "json", bitType, false, 2));
|
|
608
|
-
|
|
633
|
+
if (info2.error === void 0) return info2;
|
|
609
634
|
} catch {
|
|
610
|
-
known = false;
|
|
611
635
|
}
|
|
612
636
|
}
|
|
613
|
-
|
|
614
|
-
throw new Error(`No config found for bit: ${bitType}`);
|
|
615
|
-
}
|
|
637
|
+
throw new Error(`No config found for bit: ${bitType}`);
|
|
616
638
|
}
|
|
617
639
|
};
|
|
618
640
|
function stripUndefined(src, exclude) {
|