@markup-carve/carve-wasm 0.1.1 → 0.1.3
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 +119 -122
- package/carve_wasm.d.ts +147 -0
- package/carve_wasm.js +1 -1
- package/carve_wasm_bg.js +479 -0
- package/carve_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,20 @@ const html = toHtml('# Hello, Carve!')
|
|
|
48
48
|
document.body.innerHTML = html
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
### Source-preserving patches
|
|
52
|
+
|
|
53
|
+
Tools can prepare canonical formatting as stale-safe UTF-8 byte edits:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const patch = toCarvePatch(source)
|
|
57
|
+
const formatted = applySourcePatch(source, patch)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`createSourcePatch(source, replacement, kind, code)` prepares the same wire
|
|
61
|
+
shape for another complete replacement. Its ranges are UTF-8 byte offsets. The
|
|
62
|
+
fingerprint and byte length catch accidental staleness; they are not a
|
|
63
|
+
cryptographic signature. Treat a patch as trusted edit instructions.
|
|
64
|
+
|
|
51
65
|
### Extensions
|
|
52
66
|
|
|
53
67
|
`extensions()` reports every extension this build accepts. The list comes from
|
|
@@ -132,11 +146,25 @@ toHtmlWithOptions('# A\n\np\n', { sections: false })
|
|
|
132
146
|
toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
133
147
|
```
|
|
134
148
|
|
|
135
|
-
Every field is optional
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
Every field is optional. Omitting the object, or passing `null`, renders with
|
|
150
|
+
defaults, so the three shorthands above remain the zero-config forms.
|
|
151
|
+
|
|
152
|
+
| Field | Default | What it does |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| `sections` | `true` | Wrap each top-level heading and its content in a `<section>` |
|
|
155
|
+
| `symbols` | none | `:name:` to value, TRUSTED-RAW (see above) |
|
|
156
|
+
| `extensions` | none | Array of registry names; takes precedence over `full` |
|
|
157
|
+
| `full` | `false` | Enable the preview extension set |
|
|
158
|
+
| `rawHtml` | `true` | Emit an explicit passthrough as markup; `false` escapes it |
|
|
159
|
+
| `profile` | none | `full` / `article` / `comment` / `minimal`; rejection throws |
|
|
160
|
+
| `profileBaseHost` | none | The host the profile's link policy counts as internal |
|
|
161
|
+
| `mode` | `interactive` | `static` renders the self-contained form: no client scripts |
|
|
162
|
+
| `sourceLine` | `false` | Stamp top-level blocks with `data-source-line` |
|
|
163
|
+
| `positions` | `false` | Keep source offsets on the nodes |
|
|
164
|
+
| `labels` | none | Override engine-written strings, for a page not in English |
|
|
165
|
+
| `smartTypography` | `glyph` | `source` keeps the author's run instead of the glyph |
|
|
166
|
+
| `lowercaseHeadingIds` | `false` | Lowercase the generated heading ids |
|
|
167
|
+
| `asciiHeadingIds` | `off` | `fold` transliterates, `strict` guarantees ASCII |
|
|
140
168
|
|
|
141
169
|
An unrecognized key is ignored, because the object is configuration and a typo
|
|
142
170
|
should not break a render. A recognized key with the wrong type throws a
|
|
@@ -154,6 +182,72 @@ Nothing else changes: ids, collision dedup, `</#id>` cross-references, implicit
|
|
|
154
182
|
rather than the element carrying it. The endnotes
|
|
155
183
|
`<section role="doc-endnotes">` is a separate construct and is still emitted.
|
|
156
184
|
|
|
185
|
+
### Rendering a document you did not write
|
|
186
|
+
|
|
187
|
+
`rawHtml: false` renders an explicit passthrough - the `=html` raw block and the
|
|
188
|
+
`` `…`{=html} `` inline raw span - as escaped text instead of markup. It is the
|
|
189
|
+
switch carve-js spells `allowRawHtml`.
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
toHtmlWithOptions(fromTheReader, { rawHtml: false })
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Reach for it whenever the document comes from somewhere other than the person
|
|
196
|
+
running the page: a shared link, a comment field, a pasted file. A passthrough is
|
|
197
|
+
the one construct that puts author-controlled markup on your origin, so leaving
|
|
198
|
+
it on for a document a reader supplied is a way to run their script.
|
|
199
|
+
|
|
200
|
+
The symbols map is unaffected and stays TRUSTED-RAW either way - it is
|
|
201
|
+
configuration the host wrote, not content the document carries.
|
|
202
|
+
|
|
203
|
+
### Rendering with a profile
|
|
204
|
+
|
|
205
|
+
`rawHtml: false` closes the passthrough vector. It does not cap input length,
|
|
206
|
+
deny a construct, or constrain link schemes - that is what a profile is for, and
|
|
207
|
+
the four presets match the ones the spec and the sibling bindings describe.
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
toHtmlWithOptions(fromTheReader, { profile: 'comment', rawHtml: false })
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**A rejected document throws.** The engine's infallible entry point turns a
|
|
214
|
+
profile rejection - input past `max_length`, or a denied construct when the
|
|
215
|
+
action is Error - into an EMPTY STRING, and a caller cannot tell that from a
|
|
216
|
+
document that legitimately rendered to nothing. This binding renders through the
|
|
217
|
+
fallible one, so a rejection arrives as an `Error` whose `name` is
|
|
218
|
+
`ProfileViolationError` and whose `violations` array carries one message per
|
|
219
|
+
refused construct.
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
try {
|
|
223
|
+
html = toHtmlWithOptions(fromTheReader, { profile: 'comment' })
|
|
224
|
+
} catch (error) {
|
|
225
|
+
if (error.name === 'ProfileViolationError') report(error.violations)
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Editing a tree, and reading one back
|
|
230
|
+
|
|
231
|
+
`parseJson` serializes a document out. `astJsonToHtml` renders one back, and
|
|
232
|
+
`astJsonToCarve` writes one back as source, so a host that reads the tree in
|
|
233
|
+
order to change something can display and save the result without a server.
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
const tree = JSON.parse(parseJson(source))
|
|
237
|
+
tree.children.unshift({ type: 'heading', level: 1, children: [{ type: 'text', value: 'Added' }] })
|
|
238
|
+
const html = astJsonToHtml(JSON.stringify(tree), { full: true })
|
|
239
|
+
const carve = astJsonToCarve(JSON.stringify(tree))
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
A tree carrying something no Carve source can spell is refused by
|
|
243
|
+
`astJsonToCarve` rather than written approximately, and an invalid tree throws
|
|
244
|
+
from either.
|
|
245
|
+
|
|
246
|
+
`lintCarve` returns the degradation diagnostics as
|
|
247
|
+
`{ line, column, rule, message, start, end }`, with the rule ids carve-js and
|
|
248
|
+
carve-php use for the same triggers. Offsets are BYTE offsets into the source,
|
|
249
|
+
matching the engine.
|
|
250
|
+
|
|
157
251
|
### TypeScript
|
|
158
252
|
|
|
159
253
|
The package ships `.d.ts` declarations. Types are inferred automatically when
|
|
@@ -173,13 +267,23 @@ const html: string = toHtml('_Hello_')
|
|
|
173
267
|
| `toHtml` | `(source: string) => string` | Core renderer, no extensions |
|
|
174
268
|
| `toHtmlWithSymbols` | `(source: string, symbols?: object \| null) => string` | Core renderer + a `:name:` -> value symbols map (values are raw, see above) |
|
|
175
269
|
| `toHtmlFull` | `(source: string, symbols?: object \| null) => string` | Core + common extensions (matches playground), optional symbols map |
|
|
176
|
-
| `toHtmlWithOptions` | `(source: string, options?: object \| null) => string` | General form
|
|
270
|
+
| `toHtmlWithOptions` | `(source: string, options?: object \| null) => string` | General form; see the options table above. Throws `ProfileViolationError` when a profile rejects the document |
|
|
177
271
|
| `toHtmlWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | HTML plus bounded `raw-format-dropped` losses; strict mode throws `RenderLossError` |
|
|
178
272
|
| `toMarkdownWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked Markdown render |
|
|
179
273
|
| `toPlainTextWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked plain-text render |
|
|
180
274
|
| `toAnsiWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked ANSI render |
|
|
181
275
|
| `toCarveWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked canonical Carve render (lossless) |
|
|
182
276
|
| `parseJson` | `(source: string) => string` | The parsed AST as JSON (PART 12 exchange shape) |
|
|
277
|
+
| `astJsonToHtml` | `(json: string, options?: object \| null) => string` | Render an AST-JSON document; takes the same options object |
|
|
278
|
+
| `astJsonToCarve` | `(json: string) => string` | Write an AST-JSON document back as canonical Carve source |
|
|
279
|
+
| `lintCarve` | `(source: string) => LintWarning[]` | Degradation diagnostics, with the rule ids carve-js and carve-php share |
|
|
280
|
+
| `readStamp` | `(source: string) => { version, generatedBy } \| null` | The document's provenance marker, if it carries one |
|
|
281
|
+
| `needsReview` | `(source: string, currentVersion: string) => boolean` | Whether the stamp predates `currentVersion`; unstamped counts as yes |
|
|
282
|
+
| `fromDjot` | `(source: string) => string` | Convert Djot source to Carve |
|
|
283
|
+
| `fromBbcode` | `(source: string) => string` | Convert BBCode source to Carve; throws past the engine's size cap |
|
|
284
|
+
| `createSourcePatch` | `(source, replacement, kind, code) => SourcePatch` | Build a minimal UTF-8 byte-range patch |
|
|
285
|
+
| `toCarvePatch` | `(source: string) => SourcePatch` | Preview canonical formatting as a patch |
|
|
286
|
+
| `applySourcePatch` | `(source: string, patch: SourcePatch) => string` | Validate and apply trusted patch instructions |
|
|
183
287
|
| `version` | `() => string` | Returns the carve-wasm package version |
|
|
184
288
|
|
|
185
289
|
### The parsed AST
|
|
@@ -210,121 +314,14 @@ browser does natively and faster than building the object graph across the wasm
|
|
|
210
314
|
boundary one property at a time - and it keeps the bytes available for a caller
|
|
211
315
|
that stores or forwards them.
|
|
212
316
|
|
|
213
|
-
##
|
|
317
|
+
## Development
|
|
214
318
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
```toml
|
|
219
|
-
carve = { package = "carve-lang", git = "https://github.com/markup-carve/carve-rs", rev = "..." }
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Read the current revision out of `Cargo.toml` rather than from a copy here - a
|
|
223
|
-
revision quoted in prose goes stale the first time someone bumps the manifest
|
|
224
|
-
without noticing the duplicate.
|
|
225
|
-
|
|
226
|
-
The engine is published as `carve-lang` (carve-rs renamed it from `carve`), so a
|
|
227
|
-
pin at any revision past that rename needs `package = "carve-lang"` as above.
|
|
228
|
-
|
|
229
|
-
The crate previously tracked carve-rs' default branch with no committed lock.
|
|
230
|
-
That never went stale, but it went the other way: every build resolved whatever
|
|
231
|
-
had landed upstream since, so the published package could carry an engine no CI
|
|
232
|
-
run here had ever built, and two clones a day apart could disagree. The pin
|
|
233
|
-
makes an engine change a reviewable line in a diff.
|
|
234
|
-
|
|
235
|
-
When bumping the `rev`, regenerate and commit `Cargo.lock` in the same change.
|
|
236
|
-
The lock records the resolved revision plus the rest of the tree; leaving it
|
|
237
|
-
behind gives every fresh clone a dirty working tree on its first build and lets
|
|
238
|
-
the package resolve to an engine other than the one that was tested.
|
|
239
|
-
|
|
240
|
-
```sh
|
|
241
|
-
cargo update -p carve-lang --precise <sha> # or edit the rev and re-lock
|
|
242
|
-
cargo test && wasm-pack build --target nodejs && node tests/smoke.mjs
|
|
243
|
-
CARVE_SPEC_CORPUS=/path/to/carve/tests/corpus node tests/corpus.mjs
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
`scripts/check-engine-floor.py` is what notices a pin left behind. CI runs it
|
|
247
|
-
against the revision carve-rb embeds:
|
|
248
|
-
|
|
249
|
-
```sh
|
|
250
|
-
python3 scripts/check-engine-floor.py \
|
|
251
|
-
--engine <carve-rs checkout> --manifest Cargo.toml --lock Cargo.lock \
|
|
252
|
-
--sibling-name carve-rb --sibling-manifest <carve-rb>/ext/carve/Cargo.toml \
|
|
253
|
-
--changelog CHANGELOG.md
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
It fails when this pin is a strict ancestor of the sibling's, and it also fails
|
|
257
|
-
when the `[Unreleased]` changelog section names a revision the build does not
|
|
258
|
-
embed - a revision quoted in prose is a second copy of the pin, and the second
|
|
259
|
-
copy is the one nothing else reads. A floor rather than a leash: it is
|
|
260
|
-
deliberately not a distance check against carve-rs `main`, which merges
|
|
261
|
-
continuously and would be red from the moment any pull request opens there.
|
|
262
|
-
|
|
263
|
-
That last line is the one that can tell a drifted pin from a current one.
|
|
264
|
-
`smoke.mjs` asserts hand-written expectations, which a stale engine satisfies
|
|
265
|
-
happily; `corpus.mjs` renders all ~530 mandatory spec documents through the
|
|
266
|
-
**built** artifact and requires byte-identical HTML. Without `CARVE_SPEC_CORPUS`
|
|
267
|
-
it prints a notice and exits 0, so a checkout without the spec repo still runs
|
|
268
|
-
the suite. CI always sets it.
|
|
269
|
-
|
|
270
|
-
It measures the binding as much as the engine: carve-rs is corpus-checked
|
|
271
|
-
upstream, but that says nothing about whether the wasm-bindgen layer drops a
|
|
272
|
-
field or mangles an option on the way through.
|
|
273
|
-
|
|
274
|
-
Regenerate the whole lock MSRV-aware, or it will quietly break the `rust-version`
|
|
275
|
-
this crate advertises. A plain `cargo generate-lockfile` on a current toolchain
|
|
276
|
-
picks the newest `wasm-bindgen`, which needs a newer Rust than the 1.75 declared
|
|
277
|
-
above - fine while CI only runs `stable`, and a hard failure for anyone actually
|
|
278
|
-
building on the floor:
|
|
279
|
-
|
|
280
|
-
```sh
|
|
281
|
-
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo generate-lockfile
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
Nothing in CI catches this today, since the workflow uses `stable` only. Adding
|
|
285
|
-
a 1.75 job (carve-rs has one) would turn it from a review question into a build
|
|
286
|
-
failure.
|
|
287
|
-
|
|
288
|
-
## Build
|
|
289
|
-
|
|
290
|
-
The published package uses the **bundler** target (matching the release
|
|
291
|
-
workflow):
|
|
292
|
-
|
|
293
|
-
```bash
|
|
294
|
-
cargo test
|
|
295
|
-
wasm-pack build --target bundler --scope markup-carve
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
`wasm-pack` emits the package into `pkg/`. For a no-bundler / `<script type=module>`
|
|
299
|
-
setup use `--target web` (which exports a default `init()` you must `await`
|
|
300
|
-
before calling the renderers); for Node use `--target nodejs`.
|
|
301
|
-
|
|
302
|
-
Point the test suite at any built package with `CARVE_WASM_PKG`, rather than
|
|
303
|
-
only at `pkg/`:
|
|
304
|
-
|
|
305
|
-
```sh
|
|
306
|
-
CARVE_WASM_PKG=some/other/pkg node tests/smoke.mjs
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
Both wasm-pack targets load. Unset, it is `pkg/`, so nothing changes for the
|
|
310
|
-
ordinary loop.
|
|
311
|
-
|
|
312
|
-
## Release
|
|
313
|
-
|
|
314
|
-
Publishing is gated. `.github/workflows/release.yml` has two jobs, and
|
|
315
|
-
`publish` declares `verify` in `needs:`, so it cannot start while the gate
|
|
316
|
-
fails. The gate is `scripts/verify-release-artifact.mjs`, and it is runnable by
|
|
317
|
-
hand against a local build:
|
|
318
|
-
|
|
319
|
-
```sh
|
|
320
|
-
wasm-pack build --target bundler --scope markup-carve
|
|
321
|
-
CARVE_SPEC_CORPUS=/path/to/carve/tests/corpus node scripts/verify-release-artifact.mjs
|
|
322
|
-
```
|
|
319
|
+
The reference material a contributor needs lives in `docs/`, so this page can
|
|
320
|
+
stay about USING the package:
|
|
323
321
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
refused rather than skipped.
|
|
322
|
+
- [Building](docs/building.md) - the wasm-pack targets, pointing the tests at a
|
|
323
|
+
built package, and the rendering-only browser profile.
|
|
324
|
+
- [The carve-rs pin](docs/engine-pin.md) - why the engine is pinned to an exact
|
|
325
|
+
commit, and how to move it.
|
|
326
|
+
- [Releasing](docs/releasing.md) - the gate, what it refuses, and the runbook
|
|
327
|
+
for cutting a version.
|
package/carve_wasm.d.ts
CHANGED
|
@@ -1,6 +1,79 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
export interface LintWarning {
|
|
5
|
+
/** 1-based line number. */
|
|
6
|
+
line: number;
|
|
7
|
+
/** 1-based column number. */
|
|
8
|
+
column: number;
|
|
9
|
+
/** Stable rule id, shared with carve-js and carve-php. */
|
|
10
|
+
rule: string;
|
|
11
|
+
message: string;
|
|
12
|
+
/** 0-based BYTE offset into the source, inclusive. */
|
|
13
|
+
start: number;
|
|
14
|
+
/** 0-based BYTE offset into the source, exclusive. */
|
|
15
|
+
end: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Stamp {
|
|
19
|
+
/** The spec version the document was last processed under. */
|
|
20
|
+
version: string;
|
|
21
|
+
/** The engine that wrote the marker, when it recorded one. */
|
|
22
|
+
generatedBy: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SourceEditKind = "formatting" | "syntax-migration" | "quick-fix" | "refactor";
|
|
26
|
+
export interface SourceEdit {
|
|
27
|
+
/** Inclusive UTF-8 byte offset. */
|
|
28
|
+
start: number;
|
|
29
|
+
/** Exclusive UTF-8 byte offset. */
|
|
30
|
+
end: number;
|
|
31
|
+
replacement: string;
|
|
32
|
+
kind: SourceEditKind;
|
|
33
|
+
code: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SourceSuggestion extends SourceEdit { message: string; }
|
|
36
|
+
export interface SourcePatch {
|
|
37
|
+
version: 1;
|
|
38
|
+
sourceFingerprint: string;
|
|
39
|
+
sourceBytes: number;
|
|
40
|
+
edits: SourceEdit[];
|
|
41
|
+
unresolved: SourceSuggestion[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Apply a trusted patch after its source length and fingerprint still match.
|
|
48
|
+
*/
|
|
49
|
+
export function applySourcePatch(source: string, patch: any): string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Render an AST-JSON document (PART 12) back to canonical Carve source.
|
|
53
|
+
*
|
|
54
|
+
* The round trip a host needs to SAVE an edited tree, rather than only display
|
|
55
|
+
* it. A tree holding something no Carve source can spell is refused rather
|
|
56
|
+
* than written approximately.
|
|
57
|
+
*/
|
|
58
|
+
export function astJsonToCarve(json: string): string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Render an AST-JSON document (PART 12) to HTML.
|
|
62
|
+
*
|
|
63
|
+
* The other half of `parseJson`. A host that reads the tree in a browser does
|
|
64
|
+
* it to CHANGE something, and until now there was no way to render the result:
|
|
65
|
+
* the binding could serialize a tree out and not take one back.
|
|
66
|
+
*
|
|
67
|
+
* Takes the same options object as [`to_html_with_options`], so an edited tree
|
|
68
|
+
* renders under the profile, labels and switches the host already configured.
|
|
69
|
+
*/
|
|
70
|
+
export function astJsonToHtml(json: string, options?: object | null): string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Build the smallest single UTF-8 byte-range replacement between two sources.
|
|
74
|
+
*/
|
|
75
|
+
export function createSourcePatch(source: string, replacement: string, kind: string, code: string): SourcePatch;
|
|
76
|
+
|
|
4
77
|
/**
|
|
5
78
|
* Every extension name this build accepts, in registry order.
|
|
6
79
|
*
|
|
@@ -9,6 +82,24 @@
|
|
|
9
82
|
*/
|
|
10
83
|
export function extensions(): string[];
|
|
11
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Convert BBCode source to Carve.
|
|
87
|
+
*
|
|
88
|
+
* Rejects input past the engine's `BBCODE_MAX_INPUT_LENGTH` rather than
|
|
89
|
+
* working on it: the importer's cost is superlinear in places, and a browser
|
|
90
|
+
* host cannot afford to find that out on the main thread.
|
|
91
|
+
*/
|
|
92
|
+
export function fromBbcode(source: string): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Convert Djot source to Carve.
|
|
96
|
+
*
|
|
97
|
+
* Carve diverges from Djot deliberately - the emphasis delimiters are swapped,
|
|
98
|
+
* among others - so a Djot document is not Carve source and pasting one in
|
|
99
|
+
* renders wrongly rather than failing.
|
|
100
|
+
*/
|
|
101
|
+
export function fromDjot(source: string): string;
|
|
102
|
+
|
|
12
103
|
export function fromHtml(source: string, mode?: string | null): any;
|
|
13
104
|
|
|
14
105
|
export function fromMarkdown(source: string): any;
|
|
@@ -21,6 +112,25 @@ export function fromMarkdown(source: string): any;
|
|
|
21
112
|
*/
|
|
22
113
|
export function htmlToCarve(source: string, mode?: string | null): any;
|
|
23
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Lint a document for the degradations PART 15 describes.
|
|
117
|
+
*
|
|
118
|
+
* Returns an array of `{ line, column, rule, message, start, end }`. The rule
|
|
119
|
+
* ids are shared with carve-js and carve-php, so the same trigger reports the
|
|
120
|
+
* same id everywhere. Offsets are BYTE offsets into the source, matching the
|
|
121
|
+
* engine.
|
|
122
|
+
*
|
|
123
|
+
* Built as JS objects rather than a JSON string: a message carries arbitrary
|
|
124
|
+
* document text, and hand-rolled JSON escaping is where that goes wrong.
|
|
125
|
+
*/
|
|
126
|
+
export function lintCarve(source: string): LintWarning[];
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Whether a document was last processed under an older spec version than
|
|
130
|
+
* `currentVersion`. An unstamped document counts as needing review.
|
|
131
|
+
*/
|
|
132
|
+
export function needsReview(source: string, current_version: string): boolean;
|
|
133
|
+
|
|
24
134
|
/**
|
|
25
135
|
* Parse Carve source and return its AST as a JSON string.
|
|
26
136
|
*
|
|
@@ -41,12 +151,22 @@ export function htmlToCarve(source: string, mode?: string | null): any;
|
|
|
41
151
|
*/
|
|
42
152
|
export function parseJson(source: string): string;
|
|
43
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Read a document's provenance marker: `{ version, generatedBy }`, or `null`.
|
|
156
|
+
*/
|
|
157
|
+
export function readStamp(source: string): Stamp | null;
|
|
158
|
+
|
|
44
159
|
export function toAnsi(source: string): string;
|
|
45
160
|
|
|
46
161
|
export function toAnsiWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
47
162
|
|
|
48
163
|
export function toCarve(source: string): string;
|
|
49
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Preview canonical formatting as a source-preserving patch.
|
|
167
|
+
*/
|
|
168
|
+
export function toCarvePatch(source: string): SourcePatch;
|
|
169
|
+
|
|
50
170
|
export function toCarveWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
51
171
|
|
|
52
172
|
export function toHtml(source: string): string;
|
|
@@ -76,6 +196,8 @@ export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
|
76
196
|
* // '<h1 id="A">A</h1>\n<p>p</p>'
|
|
77
197
|
*
|
|
78
198
|
* toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
199
|
+
*
|
|
200
|
+
* toHtmlWithOptions(untrusted, { rawHtml: false })
|
|
79
201
|
* ```
|
|
80
202
|
*
|
|
81
203
|
* Every field is optional:
|
|
@@ -98,6 +220,31 @@ export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
|
98
220
|
* over `full`.
|
|
99
221
|
* * `full` (default `false`) - enable the preview extension set instead of
|
|
100
222
|
* rendering core-only.
|
|
223
|
+
* * `rawHtml` (default `true`) - render an explicit passthrough - the `=html`
|
|
224
|
+
* raw block and the `` `…`{=html} `` inline raw span - as markup. `false`
|
|
225
|
+
* emits it as escaped text instead, the same switch carve-js spells
|
|
226
|
+
* `allowRawHtml`. A host that renders a document it did not author (a shared
|
|
227
|
+
* link, a comment field, anything a reader supplies) wants `false`: without
|
|
228
|
+
* it a passthrough is a way to run script on the host's origin.
|
|
229
|
+
* * `profile` - one of `"full"`, `"article"`, `"comment"`, `"minimal"`. The
|
|
230
|
+
* rest of the untrusted-input story: input length, denied constructs, link
|
|
231
|
+
* policy. A document the profile REJECTS throws a `ProfileViolationError`
|
|
232
|
+
* carrying `violations`, rather than resolving to an empty string.
|
|
233
|
+
* * `profileBaseHost` - the host counted as internal when the profile's link
|
|
234
|
+
* policy distinguishes internal from external links.
|
|
235
|
+
* * `mode` - `"interactive"` (default) or `"static"`, the self-contained form
|
|
236
|
+
* for print, PDF and archival: no client scripts.
|
|
237
|
+
* * `sourceLine` (default `false`) - stamp top-level blocks with
|
|
238
|
+
* `data-source-line`, for editor preview scroll-sync.
|
|
239
|
+
* * `positions` (default `false`) - keep source offsets on the nodes.
|
|
240
|
+
* * `labels` - override the engine-written strings (admonition names, the
|
|
241
|
+
* endnotes heading, backlink text) for a page that is not in English. These
|
|
242
|
+
* are TEXT and are escaped where they land, unlike `symbols`.
|
|
243
|
+
* * `smartTypography` - `"glyph"` (default) resolves `...` to an ellipsis,
|
|
244
|
+
* `"source"` keeps the author's run.
|
|
245
|
+
* * `lowercaseHeadingIds` (default `false`) and `asciiHeadingIds`
|
|
246
|
+
* (`"off"` (default), `"fold"`, `"strict"`) - the slug policy, for a host
|
|
247
|
+
* whose anchors have to match another generator's.
|
|
101
248
|
*
|
|
102
249
|
* An unrecognized key is ignored: the object is configuration, and a caller
|
|
103
250
|
* who mistypes one deserves the render to still work. A wrong TYPE on a key
|
package/carve_wasm.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./carve_wasm_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
extensions, fromHtml, fromMarkdown, htmlToCarve, parseJson, toAnsi, toAnsiWithReport, toCarve, toCarveWithReport, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithReport, toHtmlWithSymbols, toMarkdown, toMarkdownWithReport, toPlainText, toPlainTextWithReport, version
|
|
8
|
+
applySourcePatch, astJsonToCarve, astJsonToHtml, createSourcePatch, extensions, fromBbcode, fromDjot, fromHtml, fromMarkdown, htmlToCarve, lintCarve, needsReview, parseJson, readStamp, toAnsi, toAnsiWithReport, toCarve, toCarvePatch, toCarveWithReport, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithReport, toHtmlWithSymbols, toMarkdown, toMarkdownWithReport, toPlainText, toPlainTextWithReport, version
|
|
9
9
|
} from "./carve_wasm_bg.js";
|
package/carve_wasm_bg.js
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a trusted patch after its source length and fingerprint still match.
|
|
3
|
+
* @param {string} source
|
|
4
|
+
* @param {any} patch
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function applySourcePatch(source, patch) {
|
|
8
|
+
let deferred3_0;
|
|
9
|
+
let deferred3_1;
|
|
10
|
+
try {
|
|
11
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.applySourcePatch(ptr0, len0, patch);
|
|
14
|
+
var ptr2 = ret[0];
|
|
15
|
+
var len2 = ret[1];
|
|
16
|
+
if (ret[3]) {
|
|
17
|
+
ptr2 = 0; len2 = 0;
|
|
18
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
19
|
+
}
|
|
20
|
+
deferred3_0 = ptr2;
|
|
21
|
+
deferred3_1 = len2;
|
|
22
|
+
return getStringFromWasm0(ptr2, len2);
|
|
23
|
+
} finally {
|
|
24
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Render an AST-JSON document (PART 12) back to canonical Carve source.
|
|
30
|
+
*
|
|
31
|
+
* The round trip a host needs to SAVE an edited tree, rather than only display
|
|
32
|
+
* it. A tree holding something no Carve source can spell is refused rather
|
|
33
|
+
* than written approximately.
|
|
34
|
+
* @param {string} json
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
export function astJsonToCarve(json) {
|
|
38
|
+
let deferred3_0;
|
|
39
|
+
let deferred3_1;
|
|
40
|
+
try {
|
|
41
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
42
|
+
const len0 = WASM_VECTOR_LEN;
|
|
43
|
+
const ret = wasm.astJsonToCarve(ptr0, len0);
|
|
44
|
+
var ptr2 = ret[0];
|
|
45
|
+
var len2 = ret[1];
|
|
46
|
+
if (ret[3]) {
|
|
47
|
+
ptr2 = 0; len2 = 0;
|
|
48
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
49
|
+
}
|
|
50
|
+
deferred3_0 = ptr2;
|
|
51
|
+
deferred3_1 = len2;
|
|
52
|
+
return getStringFromWasm0(ptr2, len2);
|
|
53
|
+
} finally {
|
|
54
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Render an AST-JSON document (PART 12) to HTML.
|
|
60
|
+
*
|
|
61
|
+
* The other half of `parseJson`. A host that reads the tree in a browser does
|
|
62
|
+
* it to CHANGE something, and until now there was no way to render the result:
|
|
63
|
+
* the binding could serialize a tree out and not take one back.
|
|
64
|
+
*
|
|
65
|
+
* Takes the same options object as [`to_html_with_options`], so an edited tree
|
|
66
|
+
* renders under the profile, labels and switches the host already configured.
|
|
67
|
+
* @param {string} json
|
|
68
|
+
* @param {object | null} [options]
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
export function astJsonToHtml(json, options) {
|
|
72
|
+
let deferred3_0;
|
|
73
|
+
let deferred3_1;
|
|
74
|
+
try {
|
|
75
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
76
|
+
const len0 = WASM_VECTOR_LEN;
|
|
77
|
+
const ret = wasm.astJsonToHtml(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
78
|
+
var ptr2 = ret[0];
|
|
79
|
+
var len2 = ret[1];
|
|
80
|
+
if (ret[3]) {
|
|
81
|
+
ptr2 = 0; len2 = 0;
|
|
82
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
83
|
+
}
|
|
84
|
+
deferred3_0 = ptr2;
|
|
85
|
+
deferred3_1 = len2;
|
|
86
|
+
return getStringFromWasm0(ptr2, len2);
|
|
87
|
+
} finally {
|
|
88
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Build the smallest single UTF-8 byte-range replacement between two sources.
|
|
94
|
+
* @param {string} source
|
|
95
|
+
* @param {string} replacement
|
|
96
|
+
* @param {string} kind
|
|
97
|
+
* @param {string} code
|
|
98
|
+
* @returns {SourcePatch}
|
|
99
|
+
*/
|
|
100
|
+
export function createSourcePatch(source, replacement, kind, code) {
|
|
101
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ptr1 = passStringToWasm0(replacement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
104
|
+
const len1 = WASM_VECTOR_LEN;
|
|
105
|
+
const ptr2 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
|
+
const len2 = WASM_VECTOR_LEN;
|
|
107
|
+
const ptr3 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
108
|
+
const len3 = WASM_VECTOR_LEN;
|
|
109
|
+
const ret = wasm.createSourcePatch(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
110
|
+
if (ret[2]) {
|
|
111
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
112
|
+
}
|
|
113
|
+
return takeFromExternrefTable0(ret[0]);
|
|
114
|
+
}
|
|
115
|
+
|
|
1
116
|
/**
|
|
2
117
|
* Every extension name this build accepts, in registry order.
|
|
3
118
|
*
|
|
@@ -12,6 +127,60 @@ export function extensions() {
|
|
|
12
127
|
return v1;
|
|
13
128
|
}
|
|
14
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Convert BBCode source to Carve.
|
|
132
|
+
*
|
|
133
|
+
* Rejects input past the engine's `BBCODE_MAX_INPUT_LENGTH` rather than
|
|
134
|
+
* working on it: the importer's cost is superlinear in places, and a browser
|
|
135
|
+
* host cannot afford to find that out on the main thread.
|
|
136
|
+
* @param {string} source
|
|
137
|
+
* @returns {string}
|
|
138
|
+
*/
|
|
139
|
+
export function fromBbcode(source) {
|
|
140
|
+
let deferred3_0;
|
|
141
|
+
let deferred3_1;
|
|
142
|
+
try {
|
|
143
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ret = wasm.fromBbcode(ptr0, len0);
|
|
146
|
+
var ptr2 = ret[0];
|
|
147
|
+
var len2 = ret[1];
|
|
148
|
+
if (ret[3]) {
|
|
149
|
+
ptr2 = 0; len2 = 0;
|
|
150
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
151
|
+
}
|
|
152
|
+
deferred3_0 = ptr2;
|
|
153
|
+
deferred3_1 = len2;
|
|
154
|
+
return getStringFromWasm0(ptr2, len2);
|
|
155
|
+
} finally {
|
|
156
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Convert Djot source to Carve.
|
|
162
|
+
*
|
|
163
|
+
* Carve diverges from Djot deliberately - the emphasis delimiters are swapped,
|
|
164
|
+
* among others - so a Djot document is not Carve source and pasting one in
|
|
165
|
+
* renders wrongly rather than failing.
|
|
166
|
+
* @param {string} source
|
|
167
|
+
* @returns {string}
|
|
168
|
+
*/
|
|
169
|
+
export function fromDjot(source) {
|
|
170
|
+
let deferred2_0;
|
|
171
|
+
let deferred2_1;
|
|
172
|
+
try {
|
|
173
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
175
|
+
const ret = wasm.fromDjot(ptr0, len0);
|
|
176
|
+
deferred2_0 = ret[0];
|
|
177
|
+
deferred2_1 = ret[1];
|
|
178
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
179
|
+
} finally {
|
|
180
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
15
184
|
/**
|
|
16
185
|
* @param {string} source
|
|
17
186
|
* @param {string | null} [mode]
|
|
@@ -64,6 +233,45 @@ export function htmlToCarve(source, mode) {
|
|
|
64
233
|
return takeFromExternrefTable0(ret[0]);
|
|
65
234
|
}
|
|
66
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Lint a document for the degradations PART 15 describes.
|
|
238
|
+
*
|
|
239
|
+
* Returns an array of `{ line, column, rule, message, start, end }`. The rule
|
|
240
|
+
* ids are shared with carve-js and carve-php, so the same trigger reports the
|
|
241
|
+
* same id everywhere. Offsets are BYTE offsets into the source, matching the
|
|
242
|
+
* engine.
|
|
243
|
+
*
|
|
244
|
+
* Built as JS objects rather than a JSON string: a message carries arbitrary
|
|
245
|
+
* document text, and hand-rolled JSON escaping is where that goes wrong.
|
|
246
|
+
* @param {string} source
|
|
247
|
+
* @returns {LintWarning[]}
|
|
248
|
+
*/
|
|
249
|
+
export function lintCarve(source) {
|
|
250
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
const ret = wasm.lintCarve(ptr0, len0);
|
|
253
|
+
if (ret[2]) {
|
|
254
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
255
|
+
}
|
|
256
|
+
return takeFromExternrefTable0(ret[0]);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Whether a document was last processed under an older spec version than
|
|
261
|
+
* `currentVersion`. An unstamped document counts as needing review.
|
|
262
|
+
* @param {string} source
|
|
263
|
+
* @param {string} current_version
|
|
264
|
+
* @returns {boolean}
|
|
265
|
+
*/
|
|
266
|
+
export function needsReview(source, current_version) {
|
|
267
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
268
|
+
const len0 = WASM_VECTOR_LEN;
|
|
269
|
+
const ptr1 = passStringToWasm0(current_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
270
|
+
const len1 = WASM_VECTOR_LEN;
|
|
271
|
+
const ret = wasm.needsReview(ptr0, len0, ptr1, len1);
|
|
272
|
+
return ret !== 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
67
275
|
/**
|
|
68
276
|
* Parse Carve source and return its AST as a JSON string.
|
|
69
277
|
*
|
|
@@ -99,6 +307,21 @@ export function parseJson(source) {
|
|
|
99
307
|
}
|
|
100
308
|
}
|
|
101
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Read a document's provenance marker: `{ version, generatedBy }`, or `null`.
|
|
312
|
+
* @param {string} source
|
|
313
|
+
* @returns {Stamp | null}
|
|
314
|
+
*/
|
|
315
|
+
export function readStamp(source) {
|
|
316
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
317
|
+
const len0 = WASM_VECTOR_LEN;
|
|
318
|
+
const ret = wasm.readStamp(ptr0, len0);
|
|
319
|
+
if (ret[2]) {
|
|
320
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
321
|
+
}
|
|
322
|
+
return takeFromExternrefTable0(ret[0]);
|
|
323
|
+
}
|
|
324
|
+
|
|
102
325
|
/**
|
|
103
326
|
* @param {string} source
|
|
104
327
|
* @returns {string}
|
|
@@ -153,6 +376,21 @@ export function toCarve(source) {
|
|
|
153
376
|
}
|
|
154
377
|
}
|
|
155
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Preview canonical formatting as a source-preserving patch.
|
|
381
|
+
* @param {string} source
|
|
382
|
+
* @returns {SourcePatch}
|
|
383
|
+
*/
|
|
384
|
+
export function toCarvePatch(source) {
|
|
385
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
+
const len0 = WASM_VECTOR_LEN;
|
|
387
|
+
const ret = wasm.toCarvePatch(ptr0, len0);
|
|
388
|
+
if (ret[2]) {
|
|
389
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
390
|
+
}
|
|
391
|
+
return takeFromExternrefTable0(ret[0]);
|
|
392
|
+
}
|
|
393
|
+
|
|
156
394
|
/**
|
|
157
395
|
* @param {string} source
|
|
158
396
|
* @param {boolean | null} [strict]
|
|
@@ -235,6 +473,8 @@ export function toHtmlFull(source, symbols) {
|
|
|
235
473
|
* // '<h1 id="A">A</h1>\n<p>p</p>'
|
|
236
474
|
*
|
|
237
475
|
* toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
476
|
+
*
|
|
477
|
+
* toHtmlWithOptions(untrusted, { rawHtml: false })
|
|
238
478
|
* ```
|
|
239
479
|
*
|
|
240
480
|
* Every field is optional:
|
|
@@ -257,6 +497,31 @@ export function toHtmlFull(source, symbols) {
|
|
|
257
497
|
* over `full`.
|
|
258
498
|
* * `full` (default `false`) - enable the preview extension set instead of
|
|
259
499
|
* rendering core-only.
|
|
500
|
+
* * `rawHtml` (default `true`) - render an explicit passthrough - the `=html`
|
|
501
|
+
* raw block and the `` `…`{=html} `` inline raw span - as markup. `false`
|
|
502
|
+
* emits it as escaped text instead, the same switch carve-js spells
|
|
503
|
+
* `allowRawHtml`. A host that renders a document it did not author (a shared
|
|
504
|
+
* link, a comment field, anything a reader supplies) wants `false`: without
|
|
505
|
+
* it a passthrough is a way to run script on the host's origin.
|
|
506
|
+
* * `profile` - one of `"full"`, `"article"`, `"comment"`, `"minimal"`. The
|
|
507
|
+
* rest of the untrusted-input story: input length, denied constructs, link
|
|
508
|
+
* policy. A document the profile REJECTS throws a `ProfileViolationError`
|
|
509
|
+
* carrying `violations`, rather than resolving to an empty string.
|
|
510
|
+
* * `profileBaseHost` - the host counted as internal when the profile's link
|
|
511
|
+
* policy distinguishes internal from external links.
|
|
512
|
+
* * `mode` - `"interactive"` (default) or `"static"`, the self-contained form
|
|
513
|
+
* for print, PDF and archival: no client scripts.
|
|
514
|
+
* * `sourceLine` (default `false`) - stamp top-level blocks with
|
|
515
|
+
* `data-source-line`, for editor preview scroll-sync.
|
|
516
|
+
* * `positions` (default `false`) - keep source offsets on the nodes.
|
|
517
|
+
* * `labels` - override the engine-written strings (admonition names, the
|
|
518
|
+
* endnotes heading, backlink text) for a page that is not in English. These
|
|
519
|
+
* are TEXT and are escaped where they land, unlike `symbols`.
|
|
520
|
+
* * `smartTypography` - `"glyph"` (default) resolves `...` to an ellipsis,
|
|
521
|
+
* `"source"` keeps the author's run.
|
|
522
|
+
* * `lowercaseHeadingIds` (default `false`) and `asciiHeadingIds`
|
|
523
|
+
* (`"off"` (default), `"fold"`, `"strict"`) - the slug policy, for a host
|
|
524
|
+
* whose anchors have to match another generator's.
|
|
260
525
|
*
|
|
261
526
|
* An unrecognized key is ignored: the object is configuration, and a caller
|
|
262
527
|
* who mistypes one deserves the render to still work. A wrong TYPE on a key
|
|
@@ -433,19 +698,82 @@ export function version() {
|
|
|
433
698
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
434
699
|
}
|
|
435
700
|
}
|
|
701
|
+
export function __wbg_Error_2e59b1b37a9a34c3(arg0, arg1) {
|
|
702
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
703
|
+
return ret;
|
|
704
|
+
}
|
|
705
|
+
export function __wbg_Number_e6ffdb596c888833(arg0) {
|
|
706
|
+
const ret = Number(arg0);
|
|
707
|
+
return ret;
|
|
708
|
+
}
|
|
709
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
710
|
+
const ret = String(arg1);
|
|
711
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
712
|
+
const len1 = WASM_VECTOR_LEN;
|
|
713
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
714
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
715
|
+
}
|
|
716
|
+
export function __wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2(arg0, arg1) {
|
|
717
|
+
const v = arg1;
|
|
718
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
719
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
720
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
721
|
+
}
|
|
436
722
|
export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
|
|
437
723
|
const v = arg0;
|
|
438
724
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
439
725
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
440
726
|
}
|
|
727
|
+
export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
|
|
728
|
+
const ret = debugString(arg1);
|
|
729
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
730
|
+
const len1 = WASM_VECTOR_LEN;
|
|
731
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
732
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
733
|
+
}
|
|
734
|
+
export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
|
|
735
|
+
const ret = arg0 in arg1;
|
|
736
|
+
return ret;
|
|
737
|
+
}
|
|
738
|
+
export function __wbg___wbindgen_is_bigint_6c98f7e945dacdde(arg0) {
|
|
739
|
+
const ret = typeof(arg0) === 'bigint';
|
|
740
|
+
return ret;
|
|
741
|
+
}
|
|
742
|
+
export function __wbg___wbindgen_is_function_49868bde5eb1e745(arg0) {
|
|
743
|
+
const ret = typeof(arg0) === 'function';
|
|
744
|
+
return ret;
|
|
745
|
+
}
|
|
441
746
|
export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
|
|
442
747
|
const ret = arg0 === null;
|
|
443
748
|
return ret;
|
|
444
749
|
}
|
|
750
|
+
export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
|
|
751
|
+
const val = arg0;
|
|
752
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
753
|
+
return ret;
|
|
754
|
+
}
|
|
755
|
+
export function __wbg___wbindgen_is_string_b29b5c5a8065ba1a(arg0) {
|
|
756
|
+
const ret = typeof(arg0) === 'string';
|
|
757
|
+
return ret;
|
|
758
|
+
}
|
|
445
759
|
export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
|
|
446
760
|
const ret = arg0 === undefined;
|
|
447
761
|
return ret;
|
|
448
762
|
}
|
|
763
|
+
export function __wbg___wbindgen_jsval_eq_7d430e744a913d26(arg0, arg1) {
|
|
764
|
+
const ret = arg0 === arg1;
|
|
765
|
+
return ret;
|
|
766
|
+
}
|
|
767
|
+
export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
|
|
768
|
+
const ret = arg0 == arg1;
|
|
769
|
+
return ret;
|
|
770
|
+
}
|
|
771
|
+
export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
|
|
772
|
+
const obj = arg1;
|
|
773
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
774
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
775
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
776
|
+
}
|
|
449
777
|
export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
|
|
450
778
|
const obj = arg1;
|
|
451
779
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
@@ -457,6 +785,14 @@ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
|
|
|
457
785
|
export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
|
|
458
786
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
459
787
|
}
|
|
788
|
+
export function __wbg_call_7f2987183bb62793() { return handleError(function (arg0, arg1) {
|
|
789
|
+
const ret = arg0.call(arg1);
|
|
790
|
+
return ret;
|
|
791
|
+
}, arguments); }
|
|
792
|
+
export function __wbg_done_547d467e97529006(arg0) {
|
|
793
|
+
const ret = arg0.done;
|
|
794
|
+
return ret;
|
|
795
|
+
}
|
|
460
796
|
export function __wbg_entries_616b1a459b85be0b(arg0) {
|
|
461
797
|
const ret = Object.entries(arg0);
|
|
462
798
|
return ret;
|
|
@@ -473,6 +809,10 @@ export function __wbg_get_4848e350b40afc16(arg0, arg1) {
|
|
|
473
809
|
const ret = arg0[arg1 >>> 0];
|
|
474
810
|
return ret;
|
|
475
811
|
}
|
|
812
|
+
export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
|
|
813
|
+
const ret = Reflect.get(arg0, arg1);
|
|
814
|
+
return ret;
|
|
815
|
+
}, arguments); }
|
|
476
816
|
export function __wbg_get_f96702c6245e4ef9() { return handleError(function (arg0, arg1) {
|
|
477
817
|
const ret = Reflect.get(arg0, arg1);
|
|
478
818
|
return ret;
|
|
@@ -481,6 +821,20 @@ export function __wbg_get_unchecked_7d7babe32e9e6a54(arg0, arg1) {
|
|
|
481
821
|
const ret = arg0[arg1 >>> 0];
|
|
482
822
|
return ret;
|
|
483
823
|
}
|
|
824
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
825
|
+
const ret = arg0[arg1];
|
|
826
|
+
return ret;
|
|
827
|
+
}
|
|
828
|
+
export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
|
|
829
|
+
let result;
|
|
830
|
+
try {
|
|
831
|
+
result = arg0 instanceof ArrayBuffer;
|
|
832
|
+
} catch (_) {
|
|
833
|
+
result = false;
|
|
834
|
+
}
|
|
835
|
+
const ret = result;
|
|
836
|
+
return ret;
|
|
837
|
+
}
|
|
484
838
|
export function __wbg_instanceof_Map_a10a2795ef4bfe97(arg0) {
|
|
485
839
|
let result;
|
|
486
840
|
try {
|
|
@@ -501,10 +855,32 @@ export function __wbg_instanceof_Object_72ee0c53dd8f0726(arg0) {
|
|
|
501
855
|
const ret = result;
|
|
502
856
|
return ret;
|
|
503
857
|
}
|
|
858
|
+
export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
|
|
859
|
+
let result;
|
|
860
|
+
try {
|
|
861
|
+
result = arg0 instanceof Uint8Array;
|
|
862
|
+
} catch (_) {
|
|
863
|
+
result = false;
|
|
864
|
+
}
|
|
865
|
+
const ret = result;
|
|
866
|
+
return ret;
|
|
867
|
+
}
|
|
504
868
|
export function __wbg_isArray_db61795ad004c139(arg0) {
|
|
505
869
|
const ret = Array.isArray(arg0);
|
|
506
870
|
return ret;
|
|
507
871
|
}
|
|
872
|
+
export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
|
|
873
|
+
const ret = Number.isSafeInteger(arg0);
|
|
874
|
+
return ret;
|
|
875
|
+
}
|
|
876
|
+
export function __wbg_iterator_de403ef31815a3e6() {
|
|
877
|
+
const ret = Symbol.iterator;
|
|
878
|
+
return ret;
|
|
879
|
+
}
|
|
880
|
+
export function __wbg_length_0c32cb8543c8e4c8(arg0) {
|
|
881
|
+
const ret = arg0.length;
|
|
882
|
+
return ret;
|
|
883
|
+
}
|
|
508
884
|
export function __wbg_length_6e821edde497a532(arg0) {
|
|
509
885
|
const ret = arg0.length;
|
|
510
886
|
return ret;
|
|
@@ -517,6 +893,10 @@ export function __wbg_new_4f9fafbb3909af72() {
|
|
|
517
893
|
const ret = new Object();
|
|
518
894
|
return ret;
|
|
519
895
|
}
|
|
896
|
+
export function __wbg_new_a560378ea1240b14(arg0) {
|
|
897
|
+
const ret = new Uint8Array(arg0);
|
|
898
|
+
return ret;
|
|
899
|
+
}
|
|
520
900
|
export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
|
|
521
901
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
522
902
|
return ret;
|
|
@@ -525,18 +905,42 @@ export function __wbg_new_f3c9df4f38f3f798() {
|
|
|
525
905
|
const ret = new Array();
|
|
526
906
|
return ret;
|
|
527
907
|
}
|
|
908
|
+
export function __wbg_next_01132ed6134b8ef5(arg0) {
|
|
909
|
+
const ret = arg0.next;
|
|
910
|
+
return ret;
|
|
911
|
+
}
|
|
912
|
+
export function __wbg_next_b3713ec761a9dbfd() { return handleError(function (arg0) {
|
|
913
|
+
const ret = arg0.next();
|
|
914
|
+
return ret;
|
|
915
|
+
}, arguments); }
|
|
528
916
|
export function __wbg_parse_545d11396395fbbd() { return handleError(function (arg0, arg1) {
|
|
529
917
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
530
918
|
return ret;
|
|
531
919
|
}, arguments); }
|
|
920
|
+
export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
|
|
921
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
922
|
+
}
|
|
532
923
|
export function __wbg_push_6bdbc990be5ac37b(arg0, arg1) {
|
|
533
924
|
const ret = arg0.push(arg1);
|
|
534
925
|
return ret;
|
|
535
926
|
}
|
|
927
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
928
|
+
arg0[arg1] = arg2;
|
|
929
|
+
}
|
|
930
|
+
export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
|
|
931
|
+
arg0[arg1 >>> 0] = arg2;
|
|
932
|
+
}
|
|
536
933
|
export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0, arg1, arg2) {
|
|
537
934
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
538
935
|
return ret;
|
|
539
936
|
}, arguments); }
|
|
937
|
+
export function __wbg_set_name_ab9c98596fd7310a(arg0, arg1, arg2) {
|
|
938
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
939
|
+
}
|
|
940
|
+
export function __wbg_value_7f6052747ccf940f(arg0) {
|
|
941
|
+
const ret = arg0.value;
|
|
942
|
+
return ret;
|
|
943
|
+
}
|
|
540
944
|
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
541
945
|
// Cast intrinsic for `F64 -> Externref`.
|
|
542
946
|
const ret = arg0;
|
|
@@ -547,6 +951,11 @@ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
|
547
951
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
548
952
|
return ret;
|
|
549
953
|
}
|
|
954
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
955
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
956
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
957
|
+
return ret;
|
|
958
|
+
}
|
|
550
959
|
export function __wbindgen_init_externref_table() {
|
|
551
960
|
const table = wasm.__wbindgen_externrefs;
|
|
552
961
|
const offset = table.grow(4);
|
|
@@ -562,6 +971,71 @@ function addToExternrefTable0(obj) {
|
|
|
562
971
|
return idx;
|
|
563
972
|
}
|
|
564
973
|
|
|
974
|
+
function debugString(val) {
|
|
975
|
+
// primitive types
|
|
976
|
+
const type = typeof val;
|
|
977
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
978
|
+
return `${val}`;
|
|
979
|
+
}
|
|
980
|
+
if (type == 'string') {
|
|
981
|
+
return `"${val}"`;
|
|
982
|
+
}
|
|
983
|
+
if (type == 'symbol') {
|
|
984
|
+
const description = val.description;
|
|
985
|
+
if (description == null) {
|
|
986
|
+
return 'Symbol';
|
|
987
|
+
} else {
|
|
988
|
+
return `Symbol(${description})`;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (type == 'function') {
|
|
992
|
+
const name = val.name;
|
|
993
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
994
|
+
return `Function(${name})`;
|
|
995
|
+
} else {
|
|
996
|
+
return 'Function';
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
// objects
|
|
1000
|
+
if (Array.isArray(val)) {
|
|
1001
|
+
const length = val.length;
|
|
1002
|
+
let debug = '[';
|
|
1003
|
+
if (length > 0) {
|
|
1004
|
+
debug += debugString(val[0]);
|
|
1005
|
+
}
|
|
1006
|
+
for(let i = 1; i < length; i++) {
|
|
1007
|
+
debug += ', ' + debugString(val[i]);
|
|
1008
|
+
}
|
|
1009
|
+
debug += ']';
|
|
1010
|
+
return debug;
|
|
1011
|
+
}
|
|
1012
|
+
// Test for built-in
|
|
1013
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1014
|
+
let className;
|
|
1015
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
1016
|
+
className = builtInMatches[1];
|
|
1017
|
+
} else {
|
|
1018
|
+
// Failed to match the standard '[object ClassName]'
|
|
1019
|
+
return toString.call(val);
|
|
1020
|
+
}
|
|
1021
|
+
if (className == 'Object') {
|
|
1022
|
+
// we're a user defined class or Object
|
|
1023
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
1024
|
+
// easier than looping through ownProperties of `val`.
|
|
1025
|
+
try {
|
|
1026
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
1027
|
+
} catch (_) {
|
|
1028
|
+
return 'Object';
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
// errors
|
|
1032
|
+
if (val instanceof Error) {
|
|
1033
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
1034
|
+
}
|
|
1035
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
1036
|
+
return className;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
565
1039
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
566
1040
|
ptr = ptr >>> 0;
|
|
567
1041
|
const mem = getDataViewMemory0();
|
|
@@ -573,6 +1047,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
573
1047
|
return result;
|
|
574
1048
|
}
|
|
575
1049
|
|
|
1050
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1051
|
+
ptr = ptr >>> 0;
|
|
1052
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
576
1055
|
let cachedDataViewMemory0 = null;
|
|
577
1056
|
function getDataViewMemory0() {
|
|
578
1057
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
package/carve_wasm_bg.wasm
CHANGED
|
Binary file
|