@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
|
@@ -409,10 +409,19 @@ declare class Builder {
|
|
|
409
409
|
* (inline marks become TextAst marks); the composer would otherwise treat
|
|
410
410
|
* them as literal text. Converts top-level JsonText fields in place.
|
|
411
411
|
* Nested (card-content) strings are left literal — documented divergence.
|
|
412
|
+
*
|
|
413
|
+
* A string body is dispatched on the bit's resolved text format, as bpg's
|
|
414
|
+
* buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
|
|
415
|
+
* (unparseable → null), and plain-text formats (text/latex/xml) stay
|
|
416
|
+
* verbatim. Tag texts are always bitmark text, independent of body format
|
|
417
|
+
* (bpg TextParser.toAst ignores format; only location matters).
|
|
412
418
|
*/
|
|
413
419
|
private parseStringTexts;
|
|
414
|
-
/**
|
|
415
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Look up the bit's config (`wasm.info`); throws bpg's exact
|
|
422
|
+
* unknown-bit-type error (`Config.getBitConfig` parity).
|
|
423
|
+
*/
|
|
424
|
+
private getBitConfig;
|
|
416
425
|
}
|
|
417
426
|
|
|
418
427
|
type ResourceMethod = (context: unknown, data: Record<string, unknown> | undefined, __typeAlias?: string) => Record<string, unknown> | undefined;
|
|
Binary file
|
|
@@ -409,10 +409,19 @@ declare class Builder {
|
|
|
409
409
|
* (inline marks become TextAst marks); the composer would otherwise treat
|
|
410
410
|
* them as literal text. Converts top-level JsonText fields in place.
|
|
411
411
|
* Nested (card-content) strings are left literal — documented divergence.
|
|
412
|
+
*
|
|
413
|
+
* A string body is dispatched on the bit's resolved text format, as bpg's
|
|
414
|
+
* buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
|
|
415
|
+
* (unparseable → null), and plain-text formats (text/latex/xml) stay
|
|
416
|
+
* verbatim. Tag texts are always bitmark text, independent of body format
|
|
417
|
+
* (bpg TextParser.toAst ignores format; only location matters).
|
|
412
418
|
*/
|
|
413
419
|
private parseStringTexts;
|
|
414
|
-
/**
|
|
415
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Look up the bit's config (`wasm.info`); throws bpg's exact
|
|
422
|
+
* unknown-bit-type error (`Config.getBitConfig` parity).
|
|
423
|
+
*/
|
|
424
|
+
private getBitConfig;
|
|
416
425
|
}
|
|
417
426
|
|
|
418
427
|
type ResourceMethod = (context: unknown, data: Record<string, unknown> | undefined, __typeAlias?: string) => Record<string, unknown> | undefined;
|
|
@@ -434,7 +434,7 @@ var bitmark_wasm_default = __wbg_init;
|
|
|
434
434
|
// src/generated/package_info.ts
|
|
435
435
|
var PACKAGE_INFO = {
|
|
436
436
|
"name": "@gmb/bitmark-parser",
|
|
437
|
-
"version": "6.3.
|
|
437
|
+
"version": "6.3.1",
|
|
438
438
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
439
439
|
"license": "ISC",
|
|
440
440
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -767,6 +767,13 @@ var DEPRECATED_TEXT_FORMATS = {
|
|
|
767
767
|
"bitmark--": "bitmark++",
|
|
768
768
|
"bitmark+": "bitmark++"
|
|
769
769
|
};
|
|
770
|
+
var CONFIG_BODY_FORMAT_TO_TEXT_FORMAT = {
|
|
771
|
+
bitmark: "bitmark++",
|
|
772
|
+
text: "text",
|
|
773
|
+
json: "json",
|
|
774
|
+
latex: "latex",
|
|
775
|
+
xml: "xml"
|
|
776
|
+
};
|
|
770
777
|
var TAG_TEXT_KEYS = [
|
|
771
778
|
"title",
|
|
772
779
|
"subtitle",
|
|
@@ -812,7 +819,7 @@ var Builder = class {
|
|
|
812
819
|
const wasm2 = getLegacyWasm();
|
|
813
820
|
const src = { ...data };
|
|
814
821
|
const bitType = src.bitType;
|
|
815
|
-
this.
|
|
822
|
+
const bitConfig = this.getBitConfig(bitType);
|
|
816
823
|
const bit = {};
|
|
817
824
|
bit.type = bitType;
|
|
818
825
|
if (src.isCommented) {
|
|
@@ -825,6 +832,8 @@ var Builder = class {
|
|
|
825
832
|
if (textFormat !== void 0) {
|
|
826
833
|
bit.format = DEPRECATED_TEXT_FORMATS[textFormat] ?? textFormat;
|
|
827
834
|
delete src.textFormat;
|
|
835
|
+
} else {
|
|
836
|
+
bit.format = CONFIG_BODY_FORMAT_TO_TEXT_FORMAT[bitConfig.bodyFormat ?? ""] ?? "bitmark++";
|
|
828
837
|
}
|
|
829
838
|
delete src.resourceType;
|
|
830
839
|
const body = src.body;
|
|
@@ -916,6 +925,12 @@ var Builder = class {
|
|
|
916
925
|
* (inline marks become TextAst marks); the composer would otherwise treat
|
|
917
926
|
* them as literal text. Converts top-level JsonText fields in place.
|
|
918
927
|
* Nested (card-content) strings are left literal — documented divergence.
|
|
928
|
+
*
|
|
929
|
+
* A string body is dispatched on the bit's resolved text format, as bpg's
|
|
930
|
+
* buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
|
|
931
|
+
* (unparseable → null), and plain-text formats (text/latex/xml) stay
|
|
932
|
+
* verbatim. Tag texts are always bitmark text, independent of body format
|
|
933
|
+
* (bpg TextParser.toAst ignores format; only location matters).
|
|
919
934
|
*/
|
|
920
935
|
parseStringTexts(bit) {
|
|
921
936
|
const wasm2 = getLegacyWasm();
|
|
@@ -930,29 +945,36 @@ var Builder = class {
|
|
|
930
945
|
};
|
|
931
946
|
const format = bit.format;
|
|
932
947
|
const bitmarkBody = format === void 0 || format === "bitmark++" || format === "bitmark+";
|
|
933
|
-
if (typeof bit.body === "string"
|
|
934
|
-
|
|
948
|
+
if (typeof bit.body === "string") {
|
|
949
|
+
if (format === "json") {
|
|
950
|
+
try {
|
|
951
|
+
bit.body = JSON.parse(bit.body);
|
|
952
|
+
} catch {
|
|
953
|
+
bit.body = null;
|
|
954
|
+
}
|
|
955
|
+
} else if (bitmarkBody) {
|
|
956
|
+
bit.body = toAst(bit.body, "body");
|
|
957
|
+
}
|
|
935
958
|
}
|
|
936
959
|
for (const key of TAG_TEXT_KEYS) {
|
|
937
960
|
const v = bit[key];
|
|
938
961
|
if (typeof v === "string") bit[key] = toAst(v, "tag");
|
|
939
962
|
}
|
|
940
963
|
}
|
|
941
|
-
/**
|
|
942
|
-
|
|
964
|
+
/**
|
|
965
|
+
* Look up the bit's config (`wasm.info`); throws bpg's exact
|
|
966
|
+
* unknown-bit-type error (`Config.getBitConfig` parity).
|
|
967
|
+
*/
|
|
968
|
+
getBitConfig(bitType) {
|
|
943
969
|
const wasm2 = getLegacyWasm();
|
|
944
|
-
let known = false;
|
|
945
970
|
if (bitType !== void 0) {
|
|
946
971
|
try {
|
|
947
972
|
const info3 = JSON.parse(wasm2.info("bit", "json", bitType, false, 2));
|
|
948
|
-
|
|
973
|
+
if (info3.error === void 0) return info3;
|
|
949
974
|
} catch {
|
|
950
|
-
known = false;
|
|
951
975
|
}
|
|
952
976
|
}
|
|
953
|
-
|
|
954
|
-
throw new Error(`No config found for bit: ${bitType}`);
|
|
955
|
-
}
|
|
977
|
+
throw new Error(`No config found for bit: ${bitType}`);
|
|
956
978
|
}
|
|
957
979
|
};
|
|
958
980
|
function stripUndefined(src, exclude) {
|