@markup-carve/carve-wasm 0.1.0 → 0.1.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 +151 -6
- package/carve_wasm.d.ts +135 -0
- package/carve_wasm.js +1 -1
- package/carve_wasm_bg.js +407 -1
- package/carve_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,10 @@ import policy and canonical writer as carve-rs. Modes are `safe` (default),
|
|
|
27
27
|
const { value, report } = htmlToCarve('<p>Hello <strong>world</strong></p>', 'safe')
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
Portable migration code can use `fromHtml(html, mode)` and
|
|
31
|
+
`fromMarkdown(markdown)`. Both return `{ value, report }`; Markdown carries an
|
|
32
|
+
empty diagnostics list because the engine migrates the document whole.
|
|
33
|
+
|
|
30
34
|
### Core renderer
|
|
31
35
|
|
|
32
36
|
Renders Carve markup to HTML with no extensions enabled.
|
|
@@ -38,6 +42,8 @@ call.
|
|
|
38
42
|
```js
|
|
39
43
|
import { toHtml } from '@markup-carve/carve-wasm'
|
|
40
44
|
|
|
45
|
+
// The other core targets are toMarkdown, toPlainText, toAnsi, and toCarve.
|
|
46
|
+
|
|
41
47
|
const html = toHtml('# Hello, Carve!')
|
|
42
48
|
document.body.innerHTML = html
|
|
43
49
|
```
|
|
@@ -126,11 +132,25 @@ toHtmlWithOptions('# A\n\np\n', { sections: false })
|
|
|
126
132
|
toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
127
133
|
```
|
|
128
134
|
|
|
129
|
-
Every field is optional
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
Every field is optional. Omitting the object, or passing `null`, renders with
|
|
136
|
+
defaults, so the three shorthands above remain the zero-config forms.
|
|
137
|
+
|
|
138
|
+
| Field | Default | What it does |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `sections` | `true` | Wrap each top-level heading and its content in a `<section>` |
|
|
141
|
+
| `symbols` | none | `:name:` to value, TRUSTED-RAW (see above) |
|
|
142
|
+
| `extensions` | none | Array of registry names; takes precedence over `full` |
|
|
143
|
+
| `full` | `false` | Enable the preview extension set |
|
|
144
|
+
| `rawHtml` | `true` | Emit an explicit passthrough as markup; `false` escapes it |
|
|
145
|
+
| `profile` | none | `full` / `article` / `comment` / `minimal`; rejection throws |
|
|
146
|
+
| `profileBaseHost` | none | The host the profile's link policy counts as internal |
|
|
147
|
+
| `mode` | `interactive` | `static` renders the self-contained form: no client scripts |
|
|
148
|
+
| `sourceLine` | `false` | Stamp top-level blocks with `data-source-line` |
|
|
149
|
+
| `positions` | `false` | Keep source offsets on the nodes |
|
|
150
|
+
| `labels` | none | Override engine-written strings, for a page not in English |
|
|
151
|
+
| `smartTypography` | `glyph` | `source` keeps the author's run instead of the glyph |
|
|
152
|
+
| `lowercaseHeadingIds` | `false` | Lowercase the generated heading ids |
|
|
153
|
+
| `asciiHeadingIds` | `off` | `fold` transliterates, `strict` guarantees ASCII |
|
|
134
154
|
|
|
135
155
|
An unrecognized key is ignored, because the object is configuration and a typo
|
|
136
156
|
should not break a render. A recognized key with the wrong type throws a
|
|
@@ -148,6 +168,72 @@ Nothing else changes: ids, collision dedup, `</#id>` cross-references, implicit
|
|
|
148
168
|
rather than the element carrying it. The endnotes
|
|
149
169
|
`<section role="doc-endnotes">` is a separate construct and is still emitted.
|
|
150
170
|
|
|
171
|
+
### Rendering a document you did not write
|
|
172
|
+
|
|
173
|
+
`rawHtml: false` renders an explicit passthrough - the `=html` raw block and the
|
|
174
|
+
`` `…`{=html} `` inline raw span - as escaped text instead of markup. It is the
|
|
175
|
+
switch carve-js spells `allowRawHtml`.
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
toHtmlWithOptions(fromTheReader, { rawHtml: false })
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Reach for it whenever the document comes from somewhere other than the person
|
|
182
|
+
running the page: a shared link, a comment field, a pasted file. A passthrough is
|
|
183
|
+
the one construct that puts author-controlled markup on your origin, so leaving
|
|
184
|
+
it on for a document a reader supplied is a way to run their script.
|
|
185
|
+
|
|
186
|
+
The symbols map is unaffected and stays TRUSTED-RAW either way - it is
|
|
187
|
+
configuration the host wrote, not content the document carries.
|
|
188
|
+
|
|
189
|
+
### Rendering with a profile
|
|
190
|
+
|
|
191
|
+
`rawHtml: false` closes the passthrough vector. It does not cap input length,
|
|
192
|
+
deny a construct, or constrain link schemes - that is what a profile is for, and
|
|
193
|
+
the four presets match the ones the spec and the sibling bindings describe.
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
toHtmlWithOptions(fromTheReader, { profile: 'comment', rawHtml: false })
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**A rejected document throws.** The engine's infallible entry point turns a
|
|
200
|
+
profile rejection - input past `max_length`, or a denied construct when the
|
|
201
|
+
action is Error - into an EMPTY STRING, and a caller cannot tell that from a
|
|
202
|
+
document that legitimately rendered to nothing. This binding renders through the
|
|
203
|
+
fallible one, so a rejection arrives as an `Error` whose `name` is
|
|
204
|
+
`ProfileViolationError` and whose `violations` array carries one message per
|
|
205
|
+
refused construct.
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
try {
|
|
209
|
+
html = toHtmlWithOptions(fromTheReader, { profile: 'comment' })
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (error.name === 'ProfileViolationError') report(error.violations)
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Editing a tree, and reading one back
|
|
216
|
+
|
|
217
|
+
`parseJson` serializes a document out. `astJsonToHtml` renders one back, and
|
|
218
|
+
`astJsonToCarve` writes one back as source, so a host that reads the tree in
|
|
219
|
+
order to change something can display and save the result without a server.
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
const tree = JSON.parse(parseJson(source))
|
|
223
|
+
tree.children.unshift({ type: 'heading', level: 1, children: [{ type: 'text', value: 'Added' }] })
|
|
224
|
+
const html = astJsonToHtml(JSON.stringify(tree), { full: true })
|
|
225
|
+
const carve = astJsonToCarve(JSON.stringify(tree))
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
A tree carrying something no Carve source can spell is refused by
|
|
229
|
+
`astJsonToCarve` rather than written approximately, and an invalid tree throws
|
|
230
|
+
from either.
|
|
231
|
+
|
|
232
|
+
`lintCarve` returns the degradation diagnostics as
|
|
233
|
+
`{ line, column, rule, message, start, end }`, with the rule ids carve-js and
|
|
234
|
+
carve-php use for the same triggers. Offsets are BYTE offsets into the source,
|
|
235
|
+
matching the engine.
|
|
236
|
+
|
|
151
237
|
### TypeScript
|
|
152
238
|
|
|
153
239
|
The package ships `.d.ts` declarations. Types are inferred automatically when
|
|
@@ -167,8 +253,20 @@ const html: string = toHtml('_Hello_')
|
|
|
167
253
|
| `toHtml` | `(source: string) => string` | Core renderer, no extensions |
|
|
168
254
|
| `toHtmlWithSymbols` | `(source: string, symbols?: object \| null) => string` | Core renderer + a `:name:` -> value symbols map (values are raw, see above) |
|
|
169
255
|
| `toHtmlFull` | `(source: string, symbols?: object \| null) => string` | Core + common extensions (matches playground), optional symbols map |
|
|
170
|
-
| `toHtmlWithOptions` | `(source: string, options?: object \| null) => string` | General form
|
|
256
|
+
| `toHtmlWithOptions` | `(source: string, options?: object \| null) => string` | General form; see the options table above. Throws `ProfileViolationError` when a profile rejects the document |
|
|
257
|
+
| `toHtmlWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | HTML plus bounded `raw-format-dropped` losses; strict mode throws `RenderLossError` |
|
|
258
|
+
| `toMarkdownWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked Markdown render |
|
|
259
|
+
| `toPlainTextWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked plain-text render |
|
|
260
|
+
| `toAnsiWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked ANSI render |
|
|
261
|
+
| `toCarveWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked canonical Carve render (lossless) |
|
|
171
262
|
| `parseJson` | `(source: string) => string` | The parsed AST as JSON (PART 12 exchange shape) |
|
|
263
|
+
| `astJsonToHtml` | `(json: string, options?: object \| null) => string` | Render an AST-JSON document; takes the same options object |
|
|
264
|
+
| `astJsonToCarve` | `(json: string) => string` | Write an AST-JSON document back as canonical Carve source |
|
|
265
|
+
| `lintCarve` | `(source: string) => LintWarning[]` | Degradation diagnostics, with the rule ids carve-js and carve-php share |
|
|
266
|
+
| `readStamp` | `(source: string) => { version, generatedBy } \| null` | The document's provenance marker, if it carries one |
|
|
267
|
+
| `needsReview` | `(source: string, currentVersion: string) => boolean` | Whether the stamp predates `currentVersion`; unstamped counts as yes |
|
|
268
|
+
| `fromDjot` | `(source: string) => string` | Convert Djot source to Carve |
|
|
269
|
+
| `fromBbcode` | `(source: string) => string` | Convert BBCode source to Carve; throws past the engine's size cap |
|
|
172
270
|
| `version` | `() => string` | Returns the carve-wasm package version |
|
|
173
271
|
|
|
174
272
|
### The parsed AST
|
|
@@ -232,6 +330,23 @@ cargo test && wasm-pack build --target nodejs && node tests/smoke.mjs
|
|
|
232
330
|
CARVE_SPEC_CORPUS=/path/to/carve/tests/corpus node tests/corpus.mjs
|
|
233
331
|
```
|
|
234
332
|
|
|
333
|
+
`scripts/check-engine-floor.py` is what notices a pin left behind. CI runs it
|
|
334
|
+
against the revision carve-rb embeds:
|
|
335
|
+
|
|
336
|
+
```sh
|
|
337
|
+
python3 scripts/check-engine-floor.py \
|
|
338
|
+
--engine <carve-rs checkout> --manifest Cargo.toml --lock Cargo.lock \
|
|
339
|
+
--sibling-name carve-rb --sibling-manifest <carve-rb>/ext/carve/Cargo.toml \
|
|
340
|
+
--changelog CHANGELOG.md
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
It fails when this pin is a strict ancestor of the sibling's, and it also fails
|
|
344
|
+
when the `[Unreleased]` changelog section names a revision the build does not
|
|
345
|
+
embed - a revision quoted in prose is a second copy of the pin, and the second
|
|
346
|
+
copy is the one nothing else reads. A floor rather than a leash: it is
|
|
347
|
+
deliberately not a distance check against carve-rs `main`, which merges
|
|
348
|
+
continuously and would be red from the moment any pull request opens there.
|
|
349
|
+
|
|
235
350
|
That last line is the one that can tell a drifted pin from a current one.
|
|
236
351
|
`smoke.mjs` asserts hand-written expectations, which a stale engine satisfies
|
|
237
352
|
happily; `corpus.mjs` renders all ~530 mandatory spec documents through the
|
|
@@ -281,6 +396,36 @@ CARVE_WASM_PKG=some/other/pkg node tests/smoke.mjs
|
|
|
281
396
|
Both wasm-pack targets load. Unset, it is `pkg/`, so nothing changes for the
|
|
282
397
|
ordinary loop.
|
|
283
398
|
|
|
399
|
+
### Rendering-only browser build
|
|
400
|
+
|
|
401
|
+
All capabilities are enabled by default, so ordinary builds and the published
|
|
402
|
+
package keep their complete API. A browser host that only renders Carve to HTML
|
|
403
|
+
can leave the importers, reports, AST serialization, and other output formats
|
|
404
|
+
out of its artifact:
|
|
405
|
+
|
|
406
|
+
```sh
|
|
407
|
+
wasm-pack build --target web --release --out-dir pkg-render . --no-default-features
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
The basic HTML rendering exports, including `toHtml`, `toHtmlFull`, and
|
|
411
|
+
`toHtmlWithOptions`, remain available. Checked rendering through
|
|
412
|
+
`toHtmlWithReport` is part of the omitted `reports` capability. The optional
|
|
413
|
+
features are:
|
|
414
|
+
|
|
415
|
+
| Feature | Exports |
|
|
416
|
+
| --- | --- |
|
|
417
|
+
| `html-import` | `htmlToCarve`, `fromHtml` |
|
|
418
|
+
| `markdown-import` | `fromMarkdown` |
|
|
419
|
+
| `reports` | all five `*WithReport` renderers |
|
|
420
|
+
| `ast-json` | `parseJson`, `astJsonToHtml`, `astJsonToCarve` |
|
|
421
|
+
| `other-renderers` | the basic Markdown, plain-text, ANSI, and Carve renderers |
|
|
422
|
+
| `lint` | `lintCarve` |
|
|
423
|
+
| `stamp` | `readStamp`, `needsReview` |
|
|
424
|
+
| `other-imports` | `fromDjot`, `fromBbcode` |
|
|
425
|
+
|
|
426
|
+
Use a separate output directory as above if a full build also exists in the
|
|
427
|
+
checkout.
|
|
428
|
+
|
|
284
429
|
## Release
|
|
285
430
|
|
|
286
431
|
Publishing is gated. `.github/workflows/release.yml` has two jobs, and
|
package/carve_wasm.d.ts
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
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
|
+
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Render an AST-JSON document (PART 12) back to canonical Carve source.
|
|
29
|
+
*
|
|
30
|
+
* The round trip a host needs to SAVE an edited tree, rather than only display
|
|
31
|
+
* it. A tree holding something no Carve source can spell is refused rather
|
|
32
|
+
* than written approximately.
|
|
33
|
+
*/
|
|
34
|
+
export function astJsonToCarve(json: string): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Render an AST-JSON document (PART 12) to HTML.
|
|
38
|
+
*
|
|
39
|
+
* The other half of `parseJson`. A host that reads the tree in a browser does
|
|
40
|
+
* it to CHANGE something, and until now there was no way to render the result:
|
|
41
|
+
* the binding could serialize a tree out and not take one back.
|
|
42
|
+
*
|
|
43
|
+
* Takes the same options object as [`to_html_with_options`], so an edited tree
|
|
44
|
+
* renders under the profile, labels and switches the host already configured.
|
|
45
|
+
*/
|
|
46
|
+
export function astJsonToHtml(json: string, options?: object | null): string;
|
|
47
|
+
|
|
4
48
|
/**
|
|
5
49
|
* Every extension name this build accepts, in registry order.
|
|
6
50
|
*
|
|
@@ -9,6 +53,28 @@
|
|
|
9
53
|
*/
|
|
10
54
|
export function extensions(): string[];
|
|
11
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Convert BBCode source to Carve.
|
|
58
|
+
*
|
|
59
|
+
* Rejects input past the engine's `BBCODE_MAX_INPUT_LENGTH` rather than
|
|
60
|
+
* working on it: the importer's cost is superlinear in places, and a browser
|
|
61
|
+
* host cannot afford to find that out on the main thread.
|
|
62
|
+
*/
|
|
63
|
+
export function fromBbcode(source: string): string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Convert Djot source to Carve.
|
|
67
|
+
*
|
|
68
|
+
* Carve diverges from Djot deliberately - the emphasis delimiters are swapped,
|
|
69
|
+
* among others - so a Djot document is not Carve source and pasting one in
|
|
70
|
+
* renders wrongly rather than failing.
|
|
71
|
+
*/
|
|
72
|
+
export function fromDjot(source: string): string;
|
|
73
|
+
|
|
74
|
+
export function fromHtml(source: string, mode?: string | null): any;
|
|
75
|
+
|
|
76
|
+
export function fromMarkdown(source: string): any;
|
|
77
|
+
|
|
12
78
|
/**
|
|
13
79
|
* Import HTML through the Rust HTML5 DOM and canonical Carve writer.
|
|
14
80
|
*
|
|
@@ -17,6 +83,25 @@ export function extensions(): string[];
|
|
|
17
83
|
*/
|
|
18
84
|
export function htmlToCarve(source: string, mode?: string | null): any;
|
|
19
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Lint a document for the degradations PART 15 describes.
|
|
88
|
+
*
|
|
89
|
+
* Returns an array of `{ line, column, rule, message, start, end }`. The rule
|
|
90
|
+
* ids are shared with carve-js and carve-php, so the same trigger reports the
|
|
91
|
+
* same id everywhere. Offsets are BYTE offsets into the source, matching the
|
|
92
|
+
* engine.
|
|
93
|
+
*
|
|
94
|
+
* Built as JS objects rather than a JSON string: a message carries arbitrary
|
|
95
|
+
* document text, and hand-rolled JSON escaping is where that goes wrong.
|
|
96
|
+
*/
|
|
97
|
+
export function lintCarve(source: string): LintWarning[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether a document was last processed under an older spec version than
|
|
101
|
+
* `currentVersion`. An unstamped document counts as needing review.
|
|
102
|
+
*/
|
|
103
|
+
export function needsReview(source: string, current_version: string): boolean;
|
|
104
|
+
|
|
20
105
|
/**
|
|
21
106
|
* Parse Carve source and return its AST as a JSON string.
|
|
22
107
|
*
|
|
@@ -37,6 +122,19 @@ export function htmlToCarve(source: string, mode?: string | null): any;
|
|
|
37
122
|
*/
|
|
38
123
|
export function parseJson(source: string): string;
|
|
39
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Read a document's provenance marker: `{ version, generatedBy }`, or `null`.
|
|
127
|
+
*/
|
|
128
|
+
export function readStamp(source: string): Stamp | null;
|
|
129
|
+
|
|
130
|
+
export function toAnsi(source: string): string;
|
|
131
|
+
|
|
132
|
+
export function toAnsiWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
133
|
+
|
|
134
|
+
export function toCarve(source: string): string;
|
|
135
|
+
|
|
136
|
+
export function toCarveWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
137
|
+
|
|
40
138
|
export function toHtml(source: string): string;
|
|
41
139
|
|
|
42
140
|
/**
|
|
@@ -64,6 +162,8 @@ export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
|
64
162
|
* // '<h1 id="A">A</h1>\n<p>p</p>'
|
|
65
163
|
*
|
|
66
164
|
* toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
165
|
+
*
|
|
166
|
+
* toHtmlWithOptions(untrusted, { rawHtml: false })
|
|
67
167
|
* ```
|
|
68
168
|
*
|
|
69
169
|
* Every field is optional:
|
|
@@ -86,6 +186,31 @@ export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
|
86
186
|
* over `full`.
|
|
87
187
|
* * `full` (default `false`) - enable the preview extension set instead of
|
|
88
188
|
* rendering core-only.
|
|
189
|
+
* * `rawHtml` (default `true`) - render an explicit passthrough - the `=html`
|
|
190
|
+
* raw block and the `` `…`{=html} `` inline raw span - as markup. `false`
|
|
191
|
+
* emits it as escaped text instead, the same switch carve-js spells
|
|
192
|
+
* `allowRawHtml`. A host that renders a document it did not author (a shared
|
|
193
|
+
* link, a comment field, anything a reader supplies) wants `false`: without
|
|
194
|
+
* it a passthrough is a way to run script on the host's origin.
|
|
195
|
+
* * `profile` - one of `"full"`, `"article"`, `"comment"`, `"minimal"`. The
|
|
196
|
+
* rest of the untrusted-input story: input length, denied constructs, link
|
|
197
|
+
* policy. A document the profile REJECTS throws a `ProfileViolationError`
|
|
198
|
+
* carrying `violations`, rather than resolving to an empty string.
|
|
199
|
+
* * `profileBaseHost` - the host counted as internal when the profile's link
|
|
200
|
+
* policy distinguishes internal from external links.
|
|
201
|
+
* * `mode` - `"interactive"` (default) or `"static"`, the self-contained form
|
|
202
|
+
* for print, PDF and archival: no client scripts.
|
|
203
|
+
* * `sourceLine` (default `false`) - stamp top-level blocks with
|
|
204
|
+
* `data-source-line`, for editor preview scroll-sync.
|
|
205
|
+
* * `positions` (default `false`) - keep source offsets on the nodes.
|
|
206
|
+
* * `labels` - override the engine-written strings (admonition names, the
|
|
207
|
+
* endnotes heading, backlink text) for a page that is not in English. These
|
|
208
|
+
* are TEXT and are escaped where they land, unlike `symbols`.
|
|
209
|
+
* * `smartTypography` - `"glyph"` (default) resolves `...` to an ellipsis,
|
|
210
|
+
* `"source"` keeps the author's run.
|
|
211
|
+
* * `lowercaseHeadingIds` (default `false`) and `asciiHeadingIds`
|
|
212
|
+
* (`"off"` (default), `"fold"`, `"strict"`) - the slug policy, for a host
|
|
213
|
+
* whose anchors have to match another generator's.
|
|
89
214
|
*
|
|
90
215
|
* An unrecognized key is ignored: the object is configuration, and a caller
|
|
91
216
|
* who mistypes one deserves the render to still work. A wrong TYPE on a key
|
|
@@ -99,6 +224,8 @@ export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
|
99
224
|
*/
|
|
100
225
|
export function toHtmlWithOptions(source: string, options?: object | null): string;
|
|
101
226
|
|
|
227
|
+
export function toHtmlWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
228
|
+
|
|
102
229
|
/**
|
|
103
230
|
* Render with the core profile and a **symbols map**: `{ rocket: "🚀" }` (a
|
|
104
231
|
* plain object or a `Map`). A `:name:` symbol whose name is in the map renders
|
|
@@ -117,4 +244,12 @@ export function toHtmlWithOptions(source: string, options?: object | null): stri
|
|
|
117
244
|
*/
|
|
118
245
|
export function toHtmlWithSymbols(source: string, symbols?: object | null): string;
|
|
119
246
|
|
|
247
|
+
export function toMarkdown(source: string): string;
|
|
248
|
+
|
|
249
|
+
export function toMarkdownWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
250
|
+
|
|
251
|
+
export function toPlainText(source: string): string;
|
|
252
|
+
|
|
253
|
+
export function toPlainTextWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
254
|
+
|
|
120
255
|
export function version(): string;
|
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, htmlToCarve, parseJson, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithSymbols, version
|
|
8
|
+
astJsonToCarve, astJsonToHtml, extensions, fromBbcode, fromDjot, fromHtml, fromMarkdown, htmlToCarve, lintCarve, needsReview, parseJson, readStamp, toAnsi, toAnsiWithReport, toCarve, 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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render an AST-JSON document (PART 12) back to canonical Carve source.
|
|
3
|
+
*
|
|
4
|
+
* The round trip a host needs to SAVE an edited tree, rather than only display
|
|
5
|
+
* it. A tree holding something no Carve source can spell is refused rather
|
|
6
|
+
* than written approximately.
|
|
7
|
+
* @param {string} json
|
|
8
|
+
* @returns {string}
|
|
9
|
+
*/
|
|
10
|
+
export function astJsonToCarve(json) {
|
|
11
|
+
let deferred3_0;
|
|
12
|
+
let deferred3_1;
|
|
13
|
+
try {
|
|
14
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
15
|
+
const len0 = WASM_VECTOR_LEN;
|
|
16
|
+
const ret = wasm.astJsonToCarve(ptr0, len0);
|
|
17
|
+
var ptr2 = ret[0];
|
|
18
|
+
var len2 = ret[1];
|
|
19
|
+
if (ret[3]) {
|
|
20
|
+
ptr2 = 0; len2 = 0;
|
|
21
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
22
|
+
}
|
|
23
|
+
deferred3_0 = ptr2;
|
|
24
|
+
deferred3_1 = len2;
|
|
25
|
+
return getStringFromWasm0(ptr2, len2);
|
|
26
|
+
} finally {
|
|
27
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Render an AST-JSON document (PART 12) to HTML.
|
|
33
|
+
*
|
|
34
|
+
* The other half of `parseJson`. A host that reads the tree in a browser does
|
|
35
|
+
* it to CHANGE something, and until now there was no way to render the result:
|
|
36
|
+
* the binding could serialize a tree out and not take one back.
|
|
37
|
+
*
|
|
38
|
+
* Takes the same options object as [`to_html_with_options`], so an edited tree
|
|
39
|
+
* renders under the profile, labels and switches the host already configured.
|
|
40
|
+
* @param {string} json
|
|
41
|
+
* @param {object | null} [options]
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
export function astJsonToHtml(json, options) {
|
|
45
|
+
let deferred3_0;
|
|
46
|
+
let deferred3_1;
|
|
47
|
+
try {
|
|
48
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
49
|
+
const len0 = WASM_VECTOR_LEN;
|
|
50
|
+
const ret = wasm.astJsonToHtml(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
51
|
+
var ptr2 = ret[0];
|
|
52
|
+
var len2 = ret[1];
|
|
53
|
+
if (ret[3]) {
|
|
54
|
+
ptr2 = 0; len2 = 0;
|
|
55
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
56
|
+
}
|
|
57
|
+
deferred3_0 = ptr2;
|
|
58
|
+
deferred3_1 = len2;
|
|
59
|
+
return getStringFromWasm0(ptr2, len2);
|
|
60
|
+
} finally {
|
|
61
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
1
65
|
/**
|
|
2
66
|
* Every extension name this build accepts, in registry order.
|
|
3
67
|
*
|
|
@@ -12,6 +76,91 @@ export function extensions() {
|
|
|
12
76
|
return v1;
|
|
13
77
|
}
|
|
14
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Convert BBCode source to Carve.
|
|
81
|
+
*
|
|
82
|
+
* Rejects input past the engine's `BBCODE_MAX_INPUT_LENGTH` rather than
|
|
83
|
+
* working on it: the importer's cost is superlinear in places, and a browser
|
|
84
|
+
* host cannot afford to find that out on the main thread.
|
|
85
|
+
* @param {string} source
|
|
86
|
+
* @returns {string}
|
|
87
|
+
*/
|
|
88
|
+
export function fromBbcode(source) {
|
|
89
|
+
let deferred3_0;
|
|
90
|
+
let deferred3_1;
|
|
91
|
+
try {
|
|
92
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
93
|
+
const len0 = WASM_VECTOR_LEN;
|
|
94
|
+
const ret = wasm.fromBbcode(ptr0, len0);
|
|
95
|
+
var ptr2 = ret[0];
|
|
96
|
+
var len2 = ret[1];
|
|
97
|
+
if (ret[3]) {
|
|
98
|
+
ptr2 = 0; len2 = 0;
|
|
99
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
100
|
+
}
|
|
101
|
+
deferred3_0 = ptr2;
|
|
102
|
+
deferred3_1 = len2;
|
|
103
|
+
return getStringFromWasm0(ptr2, len2);
|
|
104
|
+
} finally {
|
|
105
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Convert Djot source to Carve.
|
|
111
|
+
*
|
|
112
|
+
* Carve diverges from Djot deliberately - the emphasis delimiters are swapped,
|
|
113
|
+
* among others - so a Djot document is not Carve source and pasting one in
|
|
114
|
+
* renders wrongly rather than failing.
|
|
115
|
+
* @param {string} source
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
export function fromDjot(source) {
|
|
119
|
+
let deferred2_0;
|
|
120
|
+
let deferred2_1;
|
|
121
|
+
try {
|
|
122
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
124
|
+
const ret = wasm.fromDjot(ptr0, len0);
|
|
125
|
+
deferred2_0 = ret[0];
|
|
126
|
+
deferred2_1 = ret[1];
|
|
127
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
128
|
+
} finally {
|
|
129
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {string} source
|
|
135
|
+
* @param {string | null} [mode]
|
|
136
|
+
* @returns {any}
|
|
137
|
+
*/
|
|
138
|
+
export function fromHtml(source, mode) {
|
|
139
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
var ptr1 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
var len1 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.fromHtml(ptr0, len0, ptr1, len1);
|
|
144
|
+
if (ret[2]) {
|
|
145
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
146
|
+
}
|
|
147
|
+
return takeFromExternrefTable0(ret[0]);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @param {string} source
|
|
152
|
+
* @returns {any}
|
|
153
|
+
*/
|
|
154
|
+
export function fromMarkdown(source) {
|
|
155
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
156
|
+
const len0 = WASM_VECTOR_LEN;
|
|
157
|
+
const ret = wasm.fromMarkdown(ptr0, len0);
|
|
158
|
+
if (ret[2]) {
|
|
159
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
160
|
+
}
|
|
161
|
+
return takeFromExternrefTable0(ret[0]);
|
|
162
|
+
}
|
|
163
|
+
|
|
15
164
|
/**
|
|
16
165
|
* Import HTML through the Rust HTML5 DOM and canonical Carve writer.
|
|
17
166
|
*
|
|
@@ -33,6 +182,45 @@ export function htmlToCarve(source, mode) {
|
|
|
33
182
|
return takeFromExternrefTable0(ret[0]);
|
|
34
183
|
}
|
|
35
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Lint a document for the degradations PART 15 describes.
|
|
187
|
+
*
|
|
188
|
+
* Returns an array of `{ line, column, rule, message, start, end }`. The rule
|
|
189
|
+
* ids are shared with carve-js and carve-php, so the same trigger reports the
|
|
190
|
+
* same id everywhere. Offsets are BYTE offsets into the source, matching the
|
|
191
|
+
* engine.
|
|
192
|
+
*
|
|
193
|
+
* Built as JS objects rather than a JSON string: a message carries arbitrary
|
|
194
|
+
* document text, and hand-rolled JSON escaping is where that goes wrong.
|
|
195
|
+
* @param {string} source
|
|
196
|
+
* @returns {LintWarning[]}
|
|
197
|
+
*/
|
|
198
|
+
export function lintCarve(source) {
|
|
199
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
200
|
+
const len0 = WASM_VECTOR_LEN;
|
|
201
|
+
const ret = wasm.lintCarve(ptr0, len0);
|
|
202
|
+
if (ret[2]) {
|
|
203
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
204
|
+
}
|
|
205
|
+
return takeFromExternrefTable0(ret[0]);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Whether a document was last processed under an older spec version than
|
|
210
|
+
* `currentVersion`. An unstamped document counts as needing review.
|
|
211
|
+
* @param {string} source
|
|
212
|
+
* @param {string} current_version
|
|
213
|
+
* @returns {boolean}
|
|
214
|
+
*/
|
|
215
|
+
export function needsReview(source, current_version) {
|
|
216
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
const ptr1 = passStringToWasm0(current_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
219
|
+
const len1 = WASM_VECTOR_LEN;
|
|
220
|
+
const ret = wasm.needsReview(ptr0, len0, ptr1, len1);
|
|
221
|
+
return ret !== 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
36
224
|
/**
|
|
37
225
|
* Parse Carve source and return its AST as a JSON string.
|
|
38
226
|
*
|
|
@@ -68,6 +256,91 @@ export function parseJson(source) {
|
|
|
68
256
|
}
|
|
69
257
|
}
|
|
70
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Read a document's provenance marker: `{ version, generatedBy }`, or `null`.
|
|
261
|
+
* @param {string} source
|
|
262
|
+
* @returns {Stamp | null}
|
|
263
|
+
*/
|
|
264
|
+
export function readStamp(source) {
|
|
265
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
267
|
+
const ret = wasm.readStamp(ptr0, len0);
|
|
268
|
+
if (ret[2]) {
|
|
269
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
270
|
+
}
|
|
271
|
+
return takeFromExternrefTable0(ret[0]);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @param {string} source
|
|
276
|
+
* @returns {string}
|
|
277
|
+
*/
|
|
278
|
+
export function toAnsi(source) {
|
|
279
|
+
let deferred2_0;
|
|
280
|
+
let deferred2_1;
|
|
281
|
+
try {
|
|
282
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
283
|
+
const len0 = WASM_VECTOR_LEN;
|
|
284
|
+
const ret = wasm.toAnsi(ptr0, len0);
|
|
285
|
+
deferred2_0 = ret[0];
|
|
286
|
+
deferred2_1 = ret[1];
|
|
287
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
288
|
+
} finally {
|
|
289
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @param {string} source
|
|
295
|
+
* @param {boolean | null} [strict]
|
|
296
|
+
* @param {number | null} [maximum]
|
|
297
|
+
* @returns {any}
|
|
298
|
+
*/
|
|
299
|
+
export function toAnsiWithReport(source, strict, maximum) {
|
|
300
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
301
|
+
const len0 = WASM_VECTOR_LEN;
|
|
302
|
+
const ret = wasm.toAnsiWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
303
|
+
if (ret[2]) {
|
|
304
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
305
|
+
}
|
|
306
|
+
return takeFromExternrefTable0(ret[0]);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @param {string} source
|
|
311
|
+
* @returns {string}
|
|
312
|
+
*/
|
|
313
|
+
export function toCarve(source) {
|
|
314
|
+
let deferred2_0;
|
|
315
|
+
let deferred2_1;
|
|
316
|
+
try {
|
|
317
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
const len0 = WASM_VECTOR_LEN;
|
|
319
|
+
const ret = wasm.toCarve(ptr0, len0);
|
|
320
|
+
deferred2_0 = ret[0];
|
|
321
|
+
deferred2_1 = ret[1];
|
|
322
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
323
|
+
} finally {
|
|
324
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @param {string} source
|
|
330
|
+
* @param {boolean | null} [strict]
|
|
331
|
+
* @param {number | null} [maximum]
|
|
332
|
+
* @returns {any}
|
|
333
|
+
*/
|
|
334
|
+
export function toCarveWithReport(source, strict, maximum) {
|
|
335
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
+
const len0 = WASM_VECTOR_LEN;
|
|
337
|
+
const ret = wasm.toCarveWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
338
|
+
if (ret[2]) {
|
|
339
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
340
|
+
}
|
|
341
|
+
return takeFromExternrefTable0(ret[0]);
|
|
342
|
+
}
|
|
343
|
+
|
|
71
344
|
/**
|
|
72
345
|
* @param {string} source
|
|
73
346
|
* @returns {string}
|
|
@@ -134,6 +407,8 @@ export function toHtmlFull(source, symbols) {
|
|
|
134
407
|
* // '<h1 id="A">A</h1>\n<p>p</p>'
|
|
135
408
|
*
|
|
136
409
|
* toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
410
|
+
*
|
|
411
|
+
* toHtmlWithOptions(untrusted, { rawHtml: false })
|
|
137
412
|
* ```
|
|
138
413
|
*
|
|
139
414
|
* Every field is optional:
|
|
@@ -156,6 +431,31 @@ export function toHtmlFull(source, symbols) {
|
|
|
156
431
|
* over `full`.
|
|
157
432
|
* * `full` (default `false`) - enable the preview extension set instead of
|
|
158
433
|
* rendering core-only.
|
|
434
|
+
* * `rawHtml` (default `true`) - render an explicit passthrough - the `=html`
|
|
435
|
+
* raw block and the `` `…`{=html} `` inline raw span - as markup. `false`
|
|
436
|
+
* emits it as escaped text instead, the same switch carve-js spells
|
|
437
|
+
* `allowRawHtml`. A host that renders a document it did not author (a shared
|
|
438
|
+
* link, a comment field, anything a reader supplies) wants `false`: without
|
|
439
|
+
* it a passthrough is a way to run script on the host's origin.
|
|
440
|
+
* * `profile` - one of `"full"`, `"article"`, `"comment"`, `"minimal"`. The
|
|
441
|
+
* rest of the untrusted-input story: input length, denied constructs, link
|
|
442
|
+
* policy. A document the profile REJECTS throws a `ProfileViolationError`
|
|
443
|
+
* carrying `violations`, rather than resolving to an empty string.
|
|
444
|
+
* * `profileBaseHost` - the host counted as internal when the profile's link
|
|
445
|
+
* policy distinguishes internal from external links.
|
|
446
|
+
* * `mode` - `"interactive"` (default) or `"static"`, the self-contained form
|
|
447
|
+
* for print, PDF and archival: no client scripts.
|
|
448
|
+
* * `sourceLine` (default `false`) - stamp top-level blocks with
|
|
449
|
+
* `data-source-line`, for editor preview scroll-sync.
|
|
450
|
+
* * `positions` (default `false`) - keep source offsets on the nodes.
|
|
451
|
+
* * `labels` - override the engine-written strings (admonition names, the
|
|
452
|
+
* endnotes heading, backlink text) for a page that is not in English. These
|
|
453
|
+
* are TEXT and are escaped where they land, unlike `symbols`.
|
|
454
|
+
* * `smartTypography` - `"glyph"` (default) resolves `...` to an ellipsis,
|
|
455
|
+
* `"source"` keeps the author's run.
|
|
456
|
+
* * `lowercaseHeadingIds` (default `false`) and `asciiHeadingIds`
|
|
457
|
+
* (`"off"` (default), `"fold"`, `"strict"`) - the slug policy, for a host
|
|
458
|
+
* whose anchors have to match another generator's.
|
|
159
459
|
*
|
|
160
460
|
* An unrecognized key is ignored: the object is configuration, and a caller
|
|
161
461
|
* who mistypes one deserves the render to still work. A wrong TYPE on a key
|
|
@@ -191,6 +491,22 @@ export function toHtmlWithOptions(source, options) {
|
|
|
191
491
|
}
|
|
192
492
|
}
|
|
193
493
|
|
|
494
|
+
/**
|
|
495
|
+
* @param {string} source
|
|
496
|
+
* @param {boolean | null} [strict]
|
|
497
|
+
* @param {number | null} [maximum]
|
|
498
|
+
* @returns {any}
|
|
499
|
+
*/
|
|
500
|
+
export function toHtmlWithReport(source, strict, maximum) {
|
|
501
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
502
|
+
const len0 = WASM_VECTOR_LEN;
|
|
503
|
+
const ret = wasm.toHtmlWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
504
|
+
if (ret[2]) {
|
|
505
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
506
|
+
}
|
|
507
|
+
return takeFromExternrefTable0(ret[0]);
|
|
508
|
+
}
|
|
509
|
+
|
|
194
510
|
/**
|
|
195
511
|
* Render with the core profile and a **symbols map**: `{ rocket: "🚀" }` (a
|
|
196
512
|
* plain object or a `Map`). A `:name:` symbol whose name is in the map renders
|
|
@@ -231,6 +547,76 @@ export function toHtmlWithSymbols(source, symbols) {
|
|
|
231
547
|
}
|
|
232
548
|
}
|
|
233
549
|
|
|
550
|
+
/**
|
|
551
|
+
* @param {string} source
|
|
552
|
+
* @returns {string}
|
|
553
|
+
*/
|
|
554
|
+
export function toMarkdown(source) {
|
|
555
|
+
let deferred2_0;
|
|
556
|
+
let deferred2_1;
|
|
557
|
+
try {
|
|
558
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
559
|
+
const len0 = WASM_VECTOR_LEN;
|
|
560
|
+
const ret = wasm.toMarkdown(ptr0, len0);
|
|
561
|
+
deferred2_0 = ret[0];
|
|
562
|
+
deferred2_1 = ret[1];
|
|
563
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
564
|
+
} finally {
|
|
565
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* @param {string} source
|
|
571
|
+
* @param {boolean | null} [strict]
|
|
572
|
+
* @param {number | null} [maximum]
|
|
573
|
+
* @returns {any}
|
|
574
|
+
*/
|
|
575
|
+
export function toMarkdownWithReport(source, strict, maximum) {
|
|
576
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
577
|
+
const len0 = WASM_VECTOR_LEN;
|
|
578
|
+
const ret = wasm.toMarkdownWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
579
|
+
if (ret[2]) {
|
|
580
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
581
|
+
}
|
|
582
|
+
return takeFromExternrefTable0(ret[0]);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* @param {string} source
|
|
587
|
+
* @returns {string}
|
|
588
|
+
*/
|
|
589
|
+
export function toPlainText(source) {
|
|
590
|
+
let deferred2_0;
|
|
591
|
+
let deferred2_1;
|
|
592
|
+
try {
|
|
593
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
594
|
+
const len0 = WASM_VECTOR_LEN;
|
|
595
|
+
const ret = wasm.toPlainText(ptr0, len0);
|
|
596
|
+
deferred2_0 = ret[0];
|
|
597
|
+
deferred2_1 = ret[1];
|
|
598
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
599
|
+
} finally {
|
|
600
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* @param {string} source
|
|
606
|
+
* @param {boolean | null} [strict]
|
|
607
|
+
* @param {number | null} [maximum]
|
|
608
|
+
* @returns {any}
|
|
609
|
+
*/
|
|
610
|
+
export function toPlainTextWithReport(source, strict, maximum) {
|
|
611
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
612
|
+
const len0 = WASM_VECTOR_LEN;
|
|
613
|
+
const ret = wasm.toPlainTextWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
614
|
+
if (ret[2]) {
|
|
615
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
616
|
+
}
|
|
617
|
+
return takeFromExternrefTable0(ret[0]);
|
|
618
|
+
}
|
|
619
|
+
|
|
234
620
|
/**
|
|
235
621
|
* @returns {string}
|
|
236
622
|
*/
|
|
@@ -330,15 +716,35 @@ export function __wbg_new_4f9fafbb3909af72() {
|
|
|
330
716
|
const ret = new Object();
|
|
331
717
|
return ret;
|
|
332
718
|
}
|
|
719
|
+
export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
|
|
720
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
721
|
+
return ret;
|
|
722
|
+
}
|
|
723
|
+
export function __wbg_new_f3c9df4f38f3f798() {
|
|
724
|
+
const ret = new Array();
|
|
725
|
+
return ret;
|
|
726
|
+
}
|
|
333
727
|
export function __wbg_parse_545d11396395fbbd() { return handleError(function (arg0, arg1) {
|
|
334
728
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
335
729
|
return ret;
|
|
336
730
|
}, arguments); }
|
|
731
|
+
export function __wbg_push_6bdbc990be5ac37b(arg0, arg1) {
|
|
732
|
+
const ret = arg0.push(arg1);
|
|
733
|
+
return ret;
|
|
734
|
+
}
|
|
337
735
|
export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0, arg1, arg2) {
|
|
338
736
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
339
737
|
return ret;
|
|
340
738
|
}, arguments); }
|
|
341
|
-
export function
|
|
739
|
+
export function __wbg_set_name_ab9c98596fd7310a(arg0, arg1, arg2) {
|
|
740
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
741
|
+
}
|
|
742
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
743
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
744
|
+
const ret = arg0;
|
|
745
|
+
return ret;
|
|
746
|
+
}
|
|
747
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
342
748
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
343
749
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
344
750
|
return ret;
|
package/carve_wasm_bg.wasm
CHANGED
|
Binary file
|