@markup-carve/carve-wasm 0.1.5 → 0.1.6
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 +11 -12
- package/carve_wasm.d.ts +160 -276
- package/carve_wasm.js +1 -1
- package/carve_wasm_bg.js +112 -38
- package/carve_wasm_bg.wasm +0 -0
- package/docs/compatibility.md +89 -0
- package/docs/reference.md +785 -0
- package/examples/carve-worker.mjs +35 -0
- package/examples/offsets.d.ts +3 -0
- package/examples/offsets.mjs +18 -0
- package/node/LICENSE +21 -0
- package/node/README.md +105 -0
- package/node/carve_wasm.d.ts +740 -0
- package/node/carve_wasm.js +2362 -0
- package/node/carve_wasm_bg.wasm.d.ts +75 -0
- package/node/package.json +19 -0
- package/package.json +44 -3
- package/render/LICENSE +21 -0
- package/render/README.md +105 -0
- package/render/carve_wasm.d.ts +339 -0
- package/render/carve_wasm.js +726 -0
- package/render/carve_wasm_bg.wasm +0 -0
- package/render/carve_wasm_bg.wasm.d.ts +21 -0
- package/render/package.json +22 -0
- package/web/LICENSE +21 -0
- package/web/README.md +105 -0
- package/web/carve_wasm.d.ts +840 -0
- package/web/carve_wasm.js +2397 -0
- package/web/carve_wasm_bg.wasm.d.ts +75 -0
- package/web/package.json +22 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_parsersession_free: (a: number, b: number) => void;
|
|
5
|
+
export const applyAstPatch: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
6
|
+
export const applyProfile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
7
|
+
export const applyReversibleAstPatch: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
8
|
+
export const applySourcePatch: (a: number, b: number, c: any) => [number, number, number, number];
|
|
9
|
+
export const astJsonToAnsi: (a: number, b: number, c: number) => [number, number, number, number];
|
|
10
|
+
export const astJsonToCarve: (a: number, b: number) => [number, number, number, number];
|
|
11
|
+
export const astJsonToHtml: (a: number, b: number, c: number) => [number, number, number, number];
|
|
12
|
+
export const astJsonToMarkdown: (a: number, b: number, c: number) => [number, number, number, number];
|
|
13
|
+
export const astJsonToPlainText: (a: number, b: number, c: number) => [number, number, number, number];
|
|
14
|
+
export const createAstPatch: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
15
|
+
export const createReversibleAstPatch: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
16
|
+
export const createSourcePatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
17
|
+
export const expandIncludes: (a: number, b: number, c: any) => [number, number, number];
|
|
18
|
+
export const extensions: () => [number, number];
|
|
19
|
+
export const fromBbcode: (a: number, b: number) => [number, number, number, number];
|
|
20
|
+
export const fromDjot: (a: number, b: number) => [number, number];
|
|
21
|
+
export const fromHtml: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
22
|
+
export const fromMarkdown: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const fromProseMirror: (a: number, b: number) => [number, number, number, number];
|
|
24
|
+
export const htmlToAst: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
25
|
+
export const lintAccessibility: (a: number, b: number) => [number, number, number];
|
|
26
|
+
export const lintCarve: (a: number, b: number) => [number, number, number];
|
|
27
|
+
export const lintCarveWithOptions: (a: number, b: number, c: number) => [number, number, number];
|
|
28
|
+
export const markdownToAstJson: (a: number, b: number) => [number, number];
|
|
29
|
+
export const mergeAst: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
30
|
+
export const migrateBbcode: (a: number, b: number) => [number, number, number];
|
|
31
|
+
export const migrateDjot: (a: number, b: number) => [number, number, number];
|
|
32
|
+
export const needsReview: (a: number, b: number, c: number, d: number) => number;
|
|
33
|
+
export const parseJson: (a: number, b: number) => [number, number];
|
|
34
|
+
export const parseJsonWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
35
|
+
export const parseLocator: (a: number, b: number) => [number, number, number];
|
|
36
|
+
export const parseSnapshot: (a: number, b: number) => [number, number];
|
|
37
|
+
export const parseSourceLayoutJson: (a: number, b: number) => [number, number];
|
|
38
|
+
export const parsersession_edit: (a: number, b: number, c: number) => [number, number, number, number];
|
|
39
|
+
export const parsersession_new: (a: number, b: number) => number;
|
|
40
|
+
export const parsersession_snapshot: (a: number) => [number, number];
|
|
41
|
+
export const readStamp: (a: number, b: number) => [number, number, number];
|
|
42
|
+
export const reparse: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
43
|
+
export const sanitizeSvg: (a: number, b: number, c: number) => [number, number, number];
|
|
44
|
+
export const stampCarve: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
45
|
+
export const toAnsi: (a: number, b: number) => [number, number];
|
|
46
|
+
export const toAnsiWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
47
|
+
export const toAnsiWithReport: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
48
|
+
export const toCarve: (a: number, b: number) => [number, number];
|
|
49
|
+
export const toCarvePatch: (a: number, b: number) => [number, number, number];
|
|
50
|
+
export const toCarveWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
51
|
+
export const toCarveWithReport: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
52
|
+
export const toHtml: (a: number, b: number) => [number, number];
|
|
53
|
+
export const toHtmlFull: (a: number, b: number, c: number) => [number, number, number, number];
|
|
54
|
+
export const toHtmlWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
55
|
+
export const toHtmlWithRenderers: (a: number, b: number, c: number) => [number, number, number];
|
|
56
|
+
export const toHtmlWithReport: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
57
|
+
export const toHtmlWithSymbols: (a: number, b: number, c: number) => [number, number, number, number];
|
|
58
|
+
export const toMarkdown: (a: number, b: number) => [number, number];
|
|
59
|
+
export const toMarkdownWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
60
|
+
export const toMarkdownWithReport: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
61
|
+
export const toPlainText: (a: number, b: number) => [number, number];
|
|
62
|
+
export const toPlainTextWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
63
|
+
export const toPlainTextWithReport: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
64
|
+
export const toProseMirror: (a: number, b: number) => [number, number, number];
|
|
65
|
+
export const version: () => [number, number];
|
|
66
|
+
export const htmlToCarve: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
67
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
68
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
69
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
70
|
+
export const __externref_table_alloc: () => number;
|
|
71
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
72
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
73
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
74
|
+
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
75
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@markup-carve/carve-wasm",
|
|
3
|
+
"description": "WASM bindings for the Carve parser and HTML renderer.",
|
|
4
|
+
"version": "0.1.6",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/markup-carve/carve-wasm"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"carve_wasm_bg.wasm",
|
|
12
|
+
"carve_wasm.js",
|
|
13
|
+
"carve_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "carve_wasm.js",
|
|
16
|
+
"homepage": "https://markup-carve.github.io/carve/",
|
|
17
|
+
"types": "carve_wasm.d.ts",
|
|
18
|
+
"type": "commonjs"
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@markup-carve/carve-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WASM bindings for the Carve parser and HTML renderer.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.6",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
"carve_wasm_bg.wasm",
|
|
13
13
|
"carve_wasm.js",
|
|
14
14
|
"carve_wasm_bg.js",
|
|
15
|
-
"carve_wasm.d.ts"
|
|
15
|
+
"carve_wasm.d.ts",
|
|
16
|
+
"node",
|
|
17
|
+
"web",
|
|
18
|
+
"render",
|
|
19
|
+
"docs",
|
|
20
|
+
"examples"
|
|
16
21
|
],
|
|
17
22
|
"main": "carve_wasm.js",
|
|
18
23
|
"homepage": "https://markup-carve.github.io/carve/",
|
|
@@ -20,5 +25,41 @@
|
|
|
20
25
|
"sideEffects": [
|
|
21
26
|
"./carve_wasm.js",
|
|
22
27
|
"./snippets/*"
|
|
23
|
-
]
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"node": {
|
|
32
|
+
"types": "./node/carve_wasm.d.ts",
|
|
33
|
+
"default": "./node/carve_wasm.js"
|
|
34
|
+
},
|
|
35
|
+
"types": "./carve_wasm.d.ts",
|
|
36
|
+
"default": "./carve_wasm.js"
|
|
37
|
+
},
|
|
38
|
+
"./node": {
|
|
39
|
+
"types": "./node/carve_wasm.d.ts",
|
|
40
|
+
"default": "./node/carve_wasm.js"
|
|
41
|
+
},
|
|
42
|
+
"./web": {
|
|
43
|
+
"types": "./web/carve_wasm.d.ts",
|
|
44
|
+
"default": "./web/carve_wasm.js"
|
|
45
|
+
},
|
|
46
|
+
"./render": {
|
|
47
|
+
"types": "./render/carve_wasm.d.ts",
|
|
48
|
+
"default": "./render/carve_wasm.js"
|
|
49
|
+
},
|
|
50
|
+
"./offsets": {
|
|
51
|
+
"types": "./examples/offsets.d.ts",
|
|
52
|
+
"default": "./examples/offsets.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./carve_wasm.js": "./carve_wasm.js",
|
|
55
|
+
"./carve_wasm_bg.js": "./carve_wasm_bg.js",
|
|
56
|
+
"./carve_wasm_bg.wasm": "./carve_wasm_bg.wasm",
|
|
57
|
+
"./carve_wasm.d.ts": "./carve_wasm.d.ts",
|
|
58
|
+
"./node/carve_wasm_bg.wasm": "./carve_wasm_bg.wasm",
|
|
59
|
+
"./web/carve_wasm_bg.wasm": "./carve_wasm_bg.wasm",
|
|
60
|
+
"./web/*": "./web/*",
|
|
61
|
+
"./node/*": "./node/*",
|
|
62
|
+
"./render/*": "./render/*",
|
|
63
|
+
"./package.json": "./package.json"
|
|
64
|
+
}
|
|
24
65
|
}
|
package/render/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Scherer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/render/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# carve-wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly build of the [Carve](https://markup-carve.github.io/carve/) markup
|
|
4
|
+
renderer, compiled from
|
|
5
|
+
[carve-rs](https://github.com/markup-carve/carve-rs). It runs the Rust
|
|
6
|
+
implementation in browsers and powers the **Rust (WASM)** engine in the
|
|
7
|
+
[Carve playground](https://markup-carve.github.io/carve/playground).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @markup-carve/carve-wasm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Render Carve
|
|
16
|
+
|
|
17
|
+
The package root selects synchronous Node bindings in Node and the bundler
|
|
18
|
+
build in browser bundles. The browser bundler must support native WASM imports
|
|
19
|
+
and top-level await. Vite 8.3.2 is tested. See the
|
|
20
|
+
[compatibility guide](docs/compatibility.md) for explicit browser, Node and
|
|
21
|
+
rendering-only imports.
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { toHtml, toHtmlFull, toHtmlWithOptions } from '@markup-carve/carve-wasm'
|
|
25
|
+
|
|
26
|
+
toHtml('# Hello, Carve!')
|
|
27
|
+
toHtmlFull('# Hello\n\n``` mermaid\ngraph TD; A-->B\n```\n')
|
|
28
|
+
toHtmlWithOptions(source, {
|
|
29
|
+
extensions: ['glossary', 'table-of-contents'],
|
|
30
|
+
rawHtml: false,
|
|
31
|
+
sections: true,
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`toHtml` uses the core renderer. `toHtmlFull` enables the extension set used
|
|
36
|
+
by the playground preview. `toHtmlWithOptions` lets the caller choose
|
|
37
|
+
extensions and rendering policy. Unknown extension names throw instead of
|
|
38
|
+
silently producing incomplete output.
|
|
39
|
+
|
|
40
|
+
Other core targets include `toMarkdown`, `toPlainText`, `toAnsi`, and
|
|
41
|
+
`toCarve`. Each has a `*WithOptions` form.
|
|
42
|
+
|
|
43
|
+
## Convert existing content
|
|
44
|
+
|
|
45
|
+
The package imports HTML, Markdown, Djot, and BBCode. `fromHtml`,
|
|
46
|
+
`fromMarkdown`, `migrateDjot`, and `migrateBbcode` return the converted value
|
|
47
|
+
with a fidelity report. The simpler `fromDjot` and `fromBbcode` helpers return
|
|
48
|
+
only the converted string.
|
|
49
|
+
|
|
50
|
+
Markdown, Djot, and BBCode reports currently mark fidelity as unverified. An
|
|
51
|
+
empty diagnostic list does not claim that every construct was preserved.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { fromHtml, fromMarkdown, htmlToAst, htmlToCarve } from '@markup-carve/carve-wasm'
|
|
55
|
+
|
|
56
|
+
const { value, report } = htmlToCarve('<p>Hello <strong>world</strong></p>', 'safe')
|
|
57
|
+
const { value: ast } = htmlToAst('<p>Hello <b>world</b></p>', 'safe')
|
|
58
|
+
|
|
59
|
+
fromHtml(html, 'semantic')
|
|
60
|
+
fromMarkdown(markdown)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
HTML modes are `safe` (the default), `semantic`, and trusted-only
|
|
64
|
+
`roundtrip`. `htmlToAst` returns the serialized Carve AST without passing it
|
|
65
|
+
through the source writer, so its report can differ from `htmlToCarve` when a
|
|
66
|
+
construct is representable in the tree but not in Carve source.
|
|
67
|
+
|
|
68
|
+
## Common host APIs
|
|
69
|
+
|
|
70
|
+
- `extensions()` returns the extension names supported by the bundled engine.
|
|
71
|
+
- `toCarvePatch()` and `applySourcePatch()` create and apply stale-safe UTF-8
|
|
72
|
+
byte edits.
|
|
73
|
+
- `toHtmlWithSymbols()` resolves configured `:name:` symbols. Symbol values
|
|
74
|
+
are trusted raw output and must not come from user input.
|
|
75
|
+
- `parseJson()`, `astJsonToHtml()`, and the other AST functions use the PART 12
|
|
76
|
+
AST JSON shared by Carve implementations.
|
|
77
|
+
- Include expansion calls a synchronous host resolver, records dependencies,
|
|
78
|
+
and enforces depth, byte, and call budgets. The resolver decides which paths
|
|
79
|
+
to refuse.
|
|
80
|
+
- `ParserSession` retains a document between edits and can reuse unchanged
|
|
81
|
+
plain paragraphs. Call `free()` when the editor closes. Tree patches,
|
|
82
|
+
three-way merge and ProseMirror helpers also support browser editors.
|
|
83
|
+
|
|
84
|
+
The [complete API and usage reference](docs/reference.md) documents these
|
|
85
|
+
APIs, renderer profiles, resource limits, includes, AST fields, and the
|
|
86
|
+
TypeScript declarations.
|
|
87
|
+
|
|
88
|
+
## Security
|
|
89
|
+
|
|
90
|
+
Use `rawHtml: false` with a restrictive profile such as `comment` for
|
|
91
|
+
untrusted documents. Symbols and static renderer callbacks are trusted
|
|
92
|
+
configuration and may emit unescaped HTML. Treat source patches as trusted
|
|
93
|
+
edit instructions, not as signed data. A profile rejection throws.
|
|
94
|
+
|
|
95
|
+
Carve also enforces URL-scheme and attribute hardening in the renderer. See
|
|
96
|
+
the language [security documentation](https://markup-carve.github.io/carve/security)
|
|
97
|
+
for the complete model.
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
Contributor documentation lives under `docs/`:
|
|
102
|
+
|
|
103
|
+
- [Building and testing](https://github.com/markup-carve/carve-wasm/blob/main/docs/building.md)
|
|
104
|
+
- [The carve-rs engine pin](https://github.com/markup-carve/carve-wasm/blob/main/docs/engine-pin.md)
|
|
105
|
+
- [Release process](https://github.com/markup-carve/carve-wasm/blob/main/docs/releasing.md)
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function toHtmlWithOptions(source: string, options?: RenderOptions | null): string;
|
|
6
|
+
export function toHtmlWithRenderers(source: string, options?: StaticRenderOptions | null): StaticRenderResult;
|
|
7
|
+
|
|
8
|
+
export interface IncludeContext {
|
|
9
|
+
sourcePath: string | null;
|
|
10
|
+
stack: string[];
|
|
11
|
+
depth: number;
|
|
12
|
+
}
|
|
13
|
+
export type IncludeDenial = "outside-root" | "not-found" | "no-root" | "include-denied" | "include-unresolved";
|
|
14
|
+
export interface IncludeOptions {
|
|
15
|
+
resolve: (path: string, context: IncludeContext) => string | { source: string; id?: string } | { denial: IncludeDenial } | null;
|
|
16
|
+
sourcePath?: string;
|
|
17
|
+
extensions?: string[];
|
|
18
|
+
maxDepth?: number;
|
|
19
|
+
maxBytes?: number;
|
|
20
|
+
maxResolverCalls?: number;
|
|
21
|
+
maxWarnings?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface IncludeExpansion {
|
|
24
|
+
json: string;
|
|
25
|
+
warnings: { rule: string; message: string; file: string | null }[];
|
|
26
|
+
suppressedWarnings: number;
|
|
27
|
+
dependencies: { id: string; resolved: boolean; denial: IncludeDenial | null }[];
|
|
28
|
+
chargedBytes: number;
|
|
29
|
+
resolverErrors: { path: string; message: string }[];
|
|
30
|
+
}
|
|
31
|
+
export interface SourcePosition {
|
|
32
|
+
startLine: number;
|
|
33
|
+
endLine: number;
|
|
34
|
+
startColumn: number;
|
|
35
|
+
endColumn: number;
|
|
36
|
+
/** Unicode codepoint offsets, not UTF-8 bytes or UTF-16 units. */
|
|
37
|
+
startOffset: number;
|
|
38
|
+
endOffset: number;
|
|
39
|
+
}
|
|
40
|
+
export interface RenderLoss {
|
|
41
|
+
code: string;
|
|
42
|
+
format: string;
|
|
43
|
+
target: string;
|
|
44
|
+
nodeType: string;
|
|
45
|
+
message: string;
|
|
46
|
+
pos?: SourcePosition;
|
|
47
|
+
}
|
|
48
|
+
export interface RenderResult {
|
|
49
|
+
value: string;
|
|
50
|
+
losses: RenderLoss[];
|
|
51
|
+
totalLosses: number;
|
|
52
|
+
/**
|
|
53
|
+
* How many losses each code accounts for, across the WHOLE render.
|
|
54
|
+
* `losses` is bounded, so counting codes off that array under-reports as
|
|
55
|
+
* soon as `truncated` is true; these totals do not.
|
|
56
|
+
*/
|
|
57
|
+
totalsByCode: Record<string, number>;
|
|
58
|
+
truncated: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface RenderOptions {
|
|
61
|
+
full?: boolean;
|
|
62
|
+
extensions?: string[];
|
|
63
|
+
symbols?: Record<string, string> | Map<string, string>;
|
|
64
|
+
rawHtml?: boolean;
|
|
65
|
+
sections?: boolean;
|
|
66
|
+
sourceLine?: boolean;
|
|
67
|
+
positions?: boolean;
|
|
68
|
+
lowercaseHeadingIds?: boolean;
|
|
69
|
+
asciiHeadingIds?: "off" | "fold" | "strict";
|
|
70
|
+
smartTypography?: "glyph" | "source";
|
|
71
|
+
mode?: "interactive" | "static";
|
|
72
|
+
profile?: "full" | "article" | "comment" | "minimal";
|
|
73
|
+
profileBaseHost?: string;
|
|
74
|
+
mentionUrl?: string;
|
|
75
|
+
tagUrl?: string;
|
|
76
|
+
labels?: Record<string, string>;
|
|
77
|
+
}
|
|
78
|
+
export interface StaticRenderOptions extends RenderOptions {
|
|
79
|
+
renderers?: {
|
|
80
|
+
math?: (source: string, display: boolean) => string;
|
|
81
|
+
diagrams?: Record<string, (source: string) => string>;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface LintWarning {
|
|
86
|
+
/** 1-based line number. */
|
|
87
|
+
line: number;
|
|
88
|
+
/** 1-based column number. */
|
|
89
|
+
column: number;
|
|
90
|
+
/** Stable rule id, shared with carve-js and carve-php. */
|
|
91
|
+
rule: string;
|
|
92
|
+
message: string;
|
|
93
|
+
/**
|
|
94
|
+
* 0-based offset into the source in UTF-16 CODE UNITS, inclusive. That is
|
|
95
|
+
* what indexes a JavaScript string, so `source.slice(start, end)` selects the
|
|
96
|
+
* span the warning is about. It was a UTF-8 byte offset before 0.1.6, which
|
|
97
|
+
* agreed with this on an ASCII document and not outside one.
|
|
98
|
+
*/
|
|
99
|
+
start: number;
|
|
100
|
+
/** 0-based UTF-16 code unit offset into the source, exclusive. */
|
|
101
|
+
end: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ProfileViolation {
|
|
105
|
+
/** Canonical node type that was disallowed. */
|
|
106
|
+
nodeType: string;
|
|
107
|
+
/** Machine reason: element_not_allowed | max_nesting_exceeded | link_not_allowed | image_not_allowed. */
|
|
108
|
+
reason: string;
|
|
109
|
+
/** The profile's own wording for the denial, when it carries one. */
|
|
110
|
+
reasonDescription: string | null;
|
|
111
|
+
/** The engine's prose, the same text a thrown ProfileViolationError lists. */
|
|
112
|
+
message: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ProfileFilterResult {
|
|
115
|
+
/** The filtered tree, as AST JSON. */
|
|
116
|
+
json: string;
|
|
117
|
+
violations: ProfileViolation[];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface Stamp {
|
|
121
|
+
/** The spec version the document was last processed under. */
|
|
122
|
+
version: string;
|
|
123
|
+
/** The engine that wrote the marker, when it recorded one. */
|
|
124
|
+
generatedBy: string | null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type MigrationFidelity = "preserved" | "normalized" | "degraded" | "dropped";
|
|
128
|
+
export type MigrationConfidence = "exact" | "inferred" | "fallback";
|
|
129
|
+
export interface MigrationDiagnostic {
|
|
130
|
+
code: string;
|
|
131
|
+
message: string;
|
|
132
|
+
severity: "info" | "warning" | "error";
|
|
133
|
+
fidelity: MigrationFidelity;
|
|
134
|
+
confidence: MigrationConfidence;
|
|
135
|
+
path?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface MigrationReport {
|
|
138
|
+
schemaVersion: 2;
|
|
139
|
+
sourceFormat: string;
|
|
140
|
+
mode?: string;
|
|
141
|
+
adapter?: string;
|
|
142
|
+
diagnostics: MigrationDiagnostic[];
|
|
143
|
+
}
|
|
144
|
+
export interface MigrationResult { value: string; report: MigrationReport; }
|
|
145
|
+
|
|
146
|
+
export type SourceEditKind = "formatting" | "syntax-migration" | "quick-fix" | "refactor";
|
|
147
|
+
export interface SourceEdit {
|
|
148
|
+
/** Inclusive UTF-8 byte offset. */
|
|
149
|
+
start: number;
|
|
150
|
+
/** Exclusive UTF-8 byte offset. */
|
|
151
|
+
end: number;
|
|
152
|
+
replacement: string;
|
|
153
|
+
kind: SourceEditKind;
|
|
154
|
+
code: string;
|
|
155
|
+
}
|
|
156
|
+
export interface SourceSuggestion extends SourceEdit { message: string; }
|
|
157
|
+
export interface SourcePatch {
|
|
158
|
+
version: 1;
|
|
159
|
+
sourceFingerprint: string;
|
|
160
|
+
sourceBytes: number;
|
|
161
|
+
edits: SourceEdit[];
|
|
162
|
+
unresolved: SourceSuggestion[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface StaticRendererError {
|
|
166
|
+
/** "math", or the diagram fence class. */
|
|
167
|
+
renderer: string;
|
|
168
|
+
/** Present for math callbacks only. */
|
|
169
|
+
display?: boolean;
|
|
170
|
+
/** The source the renderer was handed. */
|
|
171
|
+
source: string;
|
|
172
|
+
message: string;
|
|
173
|
+
}
|
|
174
|
+
export interface StaticRenderResult {
|
|
175
|
+
html: string;
|
|
176
|
+
/** Empty unless a render callback threw or returned a non-string. */
|
|
177
|
+
rendererErrors: StaticRendererError[];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface AccessibilityDiagnostic {
|
|
181
|
+
/** Stable rule id, e.g. a11y/image-alt. */
|
|
182
|
+
rule: string;
|
|
183
|
+
severity: "warning" | "error";
|
|
184
|
+
message: string;
|
|
185
|
+
/**
|
|
186
|
+
* 0-based Unicode CODEPOINT offset, or null when the node carried none.
|
|
187
|
+
* Codepoints, not the UTF-8 bytes `LintWarning` counts: the two lint
|
|
188
|
+
* families answer in different units.
|
|
189
|
+
*/
|
|
190
|
+
startOffset: number | null;
|
|
191
|
+
endOffset: number | null;
|
|
192
|
+
/**
|
|
193
|
+
* The same span in UTF-16 code units, which is what indexes a JavaScript
|
|
194
|
+
* string. Null exactly when `startOffset` / `endOffset` are.
|
|
195
|
+
*/
|
|
196
|
+
startUtf16: number | null;
|
|
197
|
+
endUtf16: number | null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface SanitizeSvgOptions {
|
|
201
|
+
allowStyle?: boolean;
|
|
202
|
+
allowLinks?: boolean;
|
|
203
|
+
allowAnimation?: boolean;
|
|
204
|
+
allowExternalImages?: boolean;
|
|
205
|
+
}
|
|
206
|
+
export interface SanitizeResult {
|
|
207
|
+
/** Meaningful only when ok is true. */
|
|
208
|
+
svg: string;
|
|
209
|
+
/** False when the input was not a single well-formed <svg> root. */
|
|
210
|
+
ok: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface ParsedLocator {
|
|
214
|
+
label: string | null;
|
|
215
|
+
value: string | null;
|
|
216
|
+
suffixText: string | null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface ProseMirrorResult {
|
|
220
|
+
/** The ProseMirror document, JSON-encoded. */
|
|
221
|
+
json: string;
|
|
222
|
+
/** Carve node type -> why its content is gone. */
|
|
223
|
+
dropped: Record<string, string>;
|
|
224
|
+
/** Carve node type -> why its node type is gone while its text survives. */
|
|
225
|
+
degraded: Record<string, string>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Every extension name this build accepts, in registry order.
|
|
232
|
+
*
|
|
233
|
+
* Taken from the engine, so a new extension is reachable as soon as the pin
|
|
234
|
+
* moves. Nothing here lists names.
|
|
235
|
+
*/
|
|
236
|
+
export function extensions(): string[];
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Parse the locator portion of a citation into `{ label, value, suffixText }`.
|
|
240
|
+
*
|
|
241
|
+
* A field the source did not carry is `null`. Same shape as carve-js
|
|
242
|
+
* `parseLocator`; pure, and never throws on bad input.
|
|
243
|
+
*/
|
|
244
|
+
export function parseLocator(loc: string): ParsedLocator;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Sanitize an SVG document, the helper a host embedding SVG would otherwise
|
|
248
|
+
* reimplement.
|
|
249
|
+
*
|
|
250
|
+
* `{ svg, ok }`. `ok` false means the input was not a single well-formed
|
|
251
|
+
* `<svg>` root, and a caller must then show the SOURCE rather than the input:
|
|
252
|
+
* `svg` carries nothing to display. Every option defaults to `false`, which is
|
|
253
|
+
* the strict setting.
|
|
254
|
+
*/
|
|
255
|
+
export function sanitizeSvg(source: string, options?: object | null): SanitizeResult;
|
|
256
|
+
|
|
257
|
+
export function toHtml(source: string): string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Render with the preview extension set enabled (`PREVIEW_EXTENSIONS`), so the
|
|
261
|
+
* WASM engine matches an extensions-on host such as the docs Playground rather
|
|
262
|
+
* than the core-only `toHtml`.
|
|
263
|
+
*
|
|
264
|
+
* The set is curated, not "everything the engine has": `heading-numbers` and
|
|
265
|
+
* `table-of-contents` rewrite a document that never asked for it, which is
|
|
266
|
+
* wrong for a preview. Callers who want an exact set pass `extensions` to
|
|
267
|
+
* `toHtmlWithOptions`, and `extensions()` reports what this build accepts.
|
|
268
|
+
*
|
|
269
|
+
* The optional second argument is the same **symbols map** as
|
|
270
|
+
* [`to_html_with_symbols`], with the same trusted-raw contract: mapped values
|
|
271
|
+
* are emitted UNESCAPED, so never feed it untrusted input.
|
|
272
|
+
*/
|
|
273
|
+
export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Render with the core profile and a **symbols map**: `{ rocket: "🚀" }` (a
|
|
277
|
+
* plain object or a `Map`). A `:name:` symbol whose name is in the map renders
|
|
278
|
+
* the mapped value; an unmapped `:name:` stays literal `:name:` text, and the
|
|
279
|
+
* leading word-boundary guard still applies (`a:b:c`, `10:30:`,
|
|
280
|
+
* `me@example.com` never become symbols).
|
|
281
|
+
*
|
|
282
|
+
* Names and values must both be strings; a non-string value throws a JS
|
|
283
|
+
* `TypeError`.
|
|
284
|
+
*
|
|
285
|
+
* SECURITY: a mapped value is inserted as **TRUSTED RAW output in the target
|
|
286
|
+
* format** - it is NOT escaped, the same trust class as the static `renderers`
|
|
287
|
+
* map. So `{ b: "<b>x</b>" }` emits a real `<b>` element, not escaped text.
|
|
288
|
+
* This is deliberate: processor configuration is trusted. NEVER build a
|
|
289
|
+
* symbols map out of untrusted / user-supplied input.
|
|
290
|
+
*/
|
|
291
|
+
export function toHtmlWithSymbols(source: string, symbols?: object | null): string;
|
|
292
|
+
|
|
293
|
+
export function version(): string;
|
|
294
|
+
|
|
295
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
296
|
+
|
|
297
|
+
export interface InitOutput {
|
|
298
|
+
readonly memory: WebAssembly.Memory;
|
|
299
|
+
readonly extensions: () => [number, number];
|
|
300
|
+
readonly parseLocator: (a: number, b: number) => [number, number, number];
|
|
301
|
+
readonly sanitizeSvg: (a: number, b: number, c: number) => [number, number, number];
|
|
302
|
+
readonly toHtml: (a: number, b: number) => [number, number];
|
|
303
|
+
readonly toHtmlFull: (a: number, b: number, c: number) => [number, number, number, number];
|
|
304
|
+
readonly toHtmlWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
305
|
+
readonly toHtmlWithRenderers: (a: number, b: number, c: number) => [number, number, number];
|
|
306
|
+
readonly toHtmlWithSymbols: (a: number, b: number, c: number) => [number, number, number, number];
|
|
307
|
+
readonly version: () => [number, number];
|
|
308
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
309
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
310
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
311
|
+
readonly __externref_table_alloc: () => number;
|
|
312
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
313
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
314
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
315
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
316
|
+
readonly __wbindgen_start: () => void;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
323
|
+
* a precompiled `WebAssembly.Module`.
|
|
324
|
+
*
|
|
325
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
326
|
+
*
|
|
327
|
+
* @returns {InitOutput}
|
|
328
|
+
*/
|
|
329
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
333
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
334
|
+
*
|
|
335
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
336
|
+
*
|
|
337
|
+
* @returns {Promise<InitOutput>}
|
|
338
|
+
*/
|
|
339
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|