@gmb/bitmark-parser 6.3.0 → 6.3.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/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
|
Binary file
|
|
Binary file
|
|
@@ -474,7 +474,7 @@ var bitmark_wasm_default = __wbg_init;
|
|
|
474
474
|
// src/generated/package_info.ts
|
|
475
475
|
var PACKAGE_INFO = {
|
|
476
476
|
"name": "@gmb/bitmark-parser",
|
|
477
|
-
"version": "6.3.
|
|
477
|
+
"version": "6.3.2",
|
|
478
478
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
479
479
|
"license": "ISC",
|
|
480
480
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -807,6 +807,13 @@ var DEPRECATED_TEXT_FORMATS = {
|
|
|
807
807
|
"bitmark--": "bitmark++",
|
|
808
808
|
"bitmark+": "bitmark++"
|
|
809
809
|
};
|
|
810
|
+
var CONFIG_BODY_FORMAT_TO_TEXT_FORMAT = {
|
|
811
|
+
bitmark: "bitmark++",
|
|
812
|
+
text: "text",
|
|
813
|
+
json: "json",
|
|
814
|
+
latex: "latex",
|
|
815
|
+
xml: "xml"
|
|
816
|
+
};
|
|
810
817
|
var TAG_TEXT_KEYS = [
|
|
811
818
|
"title",
|
|
812
819
|
"subtitle",
|
|
@@ -852,7 +859,7 @@ var Builder = class {
|
|
|
852
859
|
const wasm2 = getLegacyWasm();
|
|
853
860
|
const src = { ...data };
|
|
854
861
|
const bitType = src.bitType;
|
|
855
|
-
this.
|
|
862
|
+
const bitConfig = this.getBitConfig(bitType);
|
|
856
863
|
const bit = {};
|
|
857
864
|
bit.type = bitType;
|
|
858
865
|
if (src.isCommented) {
|
|
@@ -865,6 +872,8 @@ var Builder = class {
|
|
|
865
872
|
if (textFormat !== void 0) {
|
|
866
873
|
bit.format = DEPRECATED_TEXT_FORMATS[textFormat] ?? textFormat;
|
|
867
874
|
delete src.textFormat;
|
|
875
|
+
} else {
|
|
876
|
+
bit.format = CONFIG_BODY_FORMAT_TO_TEXT_FORMAT[bitConfig.bodyFormat ?? ""] ?? "bitmark++";
|
|
868
877
|
}
|
|
869
878
|
delete src.resourceType;
|
|
870
879
|
const body = src.body;
|
|
@@ -956,6 +965,12 @@ var Builder = class {
|
|
|
956
965
|
* (inline marks become TextAst marks); the composer would otherwise treat
|
|
957
966
|
* them as literal text. Converts top-level JsonText fields in place.
|
|
958
967
|
* Nested (card-content) strings are left literal — documented divergence.
|
|
968
|
+
*
|
|
969
|
+
* A string body is dispatched on the bit's resolved text format, as bpg's
|
|
970
|
+
* buildBody: bitmark text is parsed to TextAst, `json` is JSON.parsed
|
|
971
|
+
* (unparseable → null), and plain-text formats (text/latex/xml) stay
|
|
972
|
+
* verbatim. Tag texts are always bitmark text, independent of body format
|
|
973
|
+
* (bpg TextParser.toAst ignores format; only location matters).
|
|
959
974
|
*/
|
|
960
975
|
parseStringTexts(bit) {
|
|
961
976
|
const wasm2 = getLegacyWasm();
|
|
@@ -970,29 +985,36 @@ var Builder = class {
|
|
|
970
985
|
};
|
|
971
986
|
const format = bit.format;
|
|
972
987
|
const bitmarkBody = format === void 0 || format === "bitmark++" || format === "bitmark+";
|
|
973
|
-
if (typeof bit.body === "string"
|
|
974
|
-
|
|
988
|
+
if (typeof bit.body === "string") {
|
|
989
|
+
if (format === "json") {
|
|
990
|
+
try {
|
|
991
|
+
bit.body = JSON.parse(bit.body);
|
|
992
|
+
} catch {
|
|
993
|
+
bit.body = null;
|
|
994
|
+
}
|
|
995
|
+
} else if (bitmarkBody) {
|
|
996
|
+
bit.body = toAst(bit.body, "body");
|
|
997
|
+
}
|
|
975
998
|
}
|
|
976
999
|
for (const key of TAG_TEXT_KEYS) {
|
|
977
1000
|
const v = bit[key];
|
|
978
1001
|
if (typeof v === "string") bit[key] = toAst(v, "tag");
|
|
979
1002
|
}
|
|
980
1003
|
}
|
|
981
|
-
/**
|
|
982
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* Look up the bit's config (`wasm.info`); throws bpg's exact
|
|
1006
|
+
* unknown-bit-type error (`Config.getBitConfig` parity).
|
|
1007
|
+
*/
|
|
1008
|
+
getBitConfig(bitType) {
|
|
983
1009
|
const wasm2 = getLegacyWasm();
|
|
984
|
-
let known = false;
|
|
985
1010
|
if (bitType !== void 0) {
|
|
986
1011
|
try {
|
|
987
1012
|
const info3 = JSON.parse(wasm2.info("bit", "json", bitType, false, 2));
|
|
988
|
-
|
|
1013
|
+
if (info3.error === void 0) return info3;
|
|
989
1014
|
} catch {
|
|
990
|
-
known = false;
|
|
991
1015
|
}
|
|
992
1016
|
}
|
|
993
|
-
|
|
994
|
-
throw new Error(`No config found for bit: ${bitType}`);
|
|
995
|
-
}
|
|
1017
|
+
throw new Error(`No config found for bit: ${bitType}`);
|
|
996
1018
|
}
|
|
997
1019
|
};
|
|
998
1020
|
function stripUndefined(src, exclude) {
|