@gmb/bitmark-parser 7.8.0 → 7.9.0
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 +73 -4
- package/config/bitmark.json +532 -209
- package/dist/browser/bitmark-parser.min.js +6 -6
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/cjs/index.cjs +519 -267
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +73 -5
- package/dist/browser/esm/index.d.ts +73 -5
- package/dist/browser/esm/index.js +518 -267
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/esm/worker-entry.js +488 -258
- package/dist/browser/esm/worker-entry.js.map +1 -1
- package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
- package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
- package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
- package/dist/index.cjs +34 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -3
- package/dist/index.d.ts +62 -3
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/dist/legacy.cjs +19 -11
- package/dist/legacy.cjs.map +1 -1
- package/dist/legacy.d.cts +3 -1
- package/dist/legacy.d.ts +3 -1
- package/dist/legacy.js +19 -11
- package/dist/legacy.js.map +1 -1
- package/dist/worker-entry.cjs.map +1 -1
- package/package.json +7 -7
- package/schema/bitmark.schema.json +1 -1
- package/wasm/bitmark_wasm.d.ts +50 -28
- package/wasm/bitmark_wasm.js +207 -111
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +5 -2
- package/wasm/package.json +1 -1
- package/wasm-bitmark-json/bitmark_json_wasm.d.ts +71 -49
- package/wasm-bitmark-json/bitmark_json_wasm.js +255 -159
- package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
- package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +5 -2
- package/wasm-bitmark-json/package.json +1 -1
- package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +50 -28
- package/wasm-browser-full/bitmark_browser_full_wasm.js +207 -111
- package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
- package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +5 -2
- package/wasm-browser-full/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ runtime — the API surface never changes:
|
|
|
71
71
|
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
|
|
72
72
|
| `full` (Node default) | everything: rich `info` metadata + built-in translations + the semantic `diff` | ~1044 KB (~410 KB gzip) |
|
|
73
73
|
| `browser-full` (browser default) | the same conversions and `diff`, without either | ~855 KB (~353 KB gzip) |
|
|
74
|
-
| `bitmark-json` | bitmark ↔ JSON only: `convert`/`canonicalize`/`transform` (formats `auto`/`bitmark`/`json`, plus the `text`, `semantic-tokens` and `diagnostics` outputs), the editor services, `info` (JSON only), breakscape, text fragments — no `diff` | ~629 KB (~256 KB gzip) |
|
|
74
|
+
| `bitmark-json` | bitmark ↔ JSON only: `convert`/`canonicalize`/`transform` (formats `auto`/`bitmark`/`json`, plus the `text`, `semantic-tokens` and `diagnostics` outputs), the editor services, bit templates, `info` (JSON only), breakscape, text fragments — no `diff` | ~629 KB (~256 KB gzip) |
|
|
75
75
|
|
|
76
76
|
**The rule.** _Every build includes every feature, except the two
|
|
77
77
|
browser-targeted variants, which each carry an explicit exclusion list._ That
|
|
@@ -752,6 +752,56 @@ Unbreakscape text (unescape bitmark special characters).
|
|
|
752
752
|
For `bitmark++` the rule is "remove one caret from each run" whatever the
|
|
753
753
|
context, so a single inverse undoes every breakscape mode.
|
|
754
754
|
|
|
755
|
+
#### template(options: TemplateOptions): string
|
|
756
|
+
|
|
757
|
+
The template of a bit (PLAN-225): an empty, config-filtered skeleton — the
|
|
758
|
+
header, the tags an author usually writes (required ones, and those the config
|
|
759
|
+
flags `template`) with their chains, the body, and the card structure (one
|
|
760
|
+
card, every side, the first variant). Every value is the tag's default, so the
|
|
761
|
+
plain rendering parses and canonicalizes cleanly.
|
|
762
|
+
|
|
763
|
+
- `bit` — the bit name; required unless `all` is set
|
|
764
|
+
- `format` — `"text"` (default; plain bitmark), `"snippet"` (an LSP snippet,
|
|
765
|
+
`insertTextFormat: 2`: `${n:default}` per value, a choice for enums and
|
|
766
|
+
booleans with the default first, labelled body placeholders, `$0` last), or
|
|
767
|
+
`"json"` (the slot model — `bit`, `attachment`, `tags[]` with `name`,
|
|
768
|
+
`format`, `default`, `values`, `required`, `chain`; `body`; `card` with its
|
|
769
|
+
`sides` — plus the `text` and `snippet` renderings)
|
|
770
|
+
- `full` — every tag in the bit's set plus the head chain of every resource
|
|
771
|
+
type the bit may attach: a diagnostic dump, expected to validate with
|
|
772
|
+
warnings (default `false`)
|
|
773
|
+
- `includeDeprecated` — keep deprecated tags (and, with `all`, deprecated bits)
|
|
774
|
+
- `all` — every bit as one JSON object `{ [bit]: { normal, full } }`, whatever
|
|
775
|
+
`format` says (`"snippet"` throws)
|
|
776
|
+
- `pretty` / `indent` — JSON formatting
|
|
777
|
+
|
|
778
|
+
```ts
|
|
779
|
+
template({ bit: "multiple-choice" });
|
|
780
|
+
// [.multiple-choice]
|
|
781
|
+
// [@revealSolutions:false]
|
|
782
|
+
// [@additionalSolutions:]
|
|
783
|
+
//
|
|
784
|
+
// ====
|
|
785
|
+
// [+]
|
|
786
|
+
// [-]
|
|
787
|
+
// ====
|
|
788
|
+
template({ bit: "quote", format: "snippet" });
|
|
789
|
+
// [.quote]\n[@quotedPerson:${1}]\n${2:body}\n$0
|
|
790
|
+
JSON.parse(template({ bit: "image", format: "json" })).tags[0].name; // "&image"
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
Which tags are "usual" is configuration: a `template` member on a tag entry
|
|
794
|
+
(`true`, `false`, or `{ "only": { "bits": [...], "bitGroups": [...] } }` /
|
|
795
|
+
`{ "except": … }`), resolved by `bitmark-confgen` into a per-bit flag the
|
|
796
|
+
`info` views show as `template: true`. Required tags are always in the
|
|
797
|
+
template. A resource head flagged for a bit that can only reach it through a
|
|
798
|
+
header attachment puts the attachment in the header (`[.article&image]`).
|
|
799
|
+
|
|
800
|
+
`complete(input, position, { bitTemplate: true })` makes a bit-type item
|
|
801
|
+
insert the bit's normal snippet from the name onward (`article]⏎…`) — the
|
|
802
|
+
editor must then replace a `]` it auto-closed after the cursor. Available in
|
|
803
|
+
every wasm variant.
|
|
804
|
+
|
|
755
805
|
#### info(options?: InfoOptions): string
|
|
756
806
|
|
|
757
807
|
Query information about supported bit types. `"bit"`/`"all"` default to a
|
|
@@ -927,7 +977,9 @@ The normative definition of the JSON is
|
|
|
927
977
|
|
|
928
978
|
#### version(): string
|
|
929
979
|
|
|
930
|
-
Return the library version string
|
|
980
|
+
Return the library version string: the version the loaded wasm reports, so
|
|
981
|
+
it is the parser actually running. Before a wasm is loaded (in the browser,
|
|
982
|
+
before `init()`), the package's own version. Never throws.
|
|
931
983
|
|
|
932
984
|
### Typed API (generated types)
|
|
933
985
|
|
|
@@ -1089,7 +1141,8 @@ Differences (all loud, never silent):
|
|
|
1089
1141
|
at the boundary). The markup produced _inside_ `<table>` follows this
|
|
1090
1142
|
parser's html mapping and may differ from bpg's in detail.
|
|
1091
1143
|
`keepUnknownTags` / `noBreakscaping` throw.
|
|
1092
|
-
- `version()` reports this package's version (
|
|
1144
|
+
- `version()` reports this package's version (the loaded wasm's), not a bpg
|
|
1145
|
+
version.
|
|
1093
1146
|
|
|
1094
1147
|
## CLI
|
|
1095
1148
|
|
|
@@ -1163,8 +1216,16 @@ bitmark info all -f json --pretty
|
|
|
1163
1216
|
bitmark info --bit article # compact: one line per tag (format, count, default)
|
|
1164
1217
|
bitmark info --bit article --full # full detail: defaults, provenance, keys, card set
|
|
1165
1218
|
bitmark info deprecated # deprecated bits + migration targets
|
|
1166
|
-
bitmark info list --
|
|
1219
|
+
bitmark info list --include-deprecated # include deprecated bits in the listing
|
|
1167
1220
|
bitmark info list --deprecated # only deprecated bits
|
|
1221
|
+
|
|
1222
|
+
# A bit's template: the tags an author usually writes, the body and the card
|
|
1223
|
+
# structure (PLAN-225) — plain bitmark, an LSP snippet, or JSON
|
|
1224
|
+
bitmark template --bit multiple-choice
|
|
1225
|
+
bitmark template --bit flashcard -f snippet
|
|
1226
|
+
bitmark template --bit article --full # every tag + every attachable resource chain
|
|
1227
|
+
bitmark template --all --pretty # every bit, both modes, keyed by name (JSON)
|
|
1228
|
+
bitmark editor complete input.bitmark --line 0 --character 2 --bit-template # bit items insert their template
|
|
1168
1229
|
```
|
|
1169
1230
|
|
|
1170
1231
|
All commands support `-o, --output <file>` and `-a, --append` flags. Commands that accept input support file paths, literal strings, or stdin (when no arguments are given).
|
|
@@ -1196,6 +1257,14 @@ selected variant's `.wasm` (from `dist/browser/wasm/`). A bare `init()` loads
|
|
|
1196
1257
|
build, and a later `init({ feature: "full" })` upgrades in place (see _WASM
|
|
1197
1258
|
variants_).
|
|
1198
1259
|
|
|
1260
|
+
The script and the `.wasm` are one release. Loaded through a version alias
|
|
1261
|
+
such as `@latest`, the script fetches the `.wasm` from the path pinned to its
|
|
1262
|
+
own version (`…/@gmb/bitmark-parser@<version>/…`), so a script served from a
|
|
1263
|
+
CDN cache after a release never drives the new release's wasm. `init()`
|
|
1264
|
+
rejects a `.wasm` of another version (`version-mismatch: …`) rather than
|
|
1265
|
+
running it; the glue can be instantiated once per page, so a reload is the
|
|
1266
|
+
remedy.
|
|
1267
|
+
|
|
1199
1268
|
### Bundler (webpack / vite)
|
|
1200
1269
|
|
|
1201
1270
|
```js
|