satteri 0.10.4 → 0.11.1
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 -0
- package/dist/arena-reader.d.ts +13 -0
- package/dist/arena-reader.js +104 -0
- package/dist/binding.browser.d.ts +1 -1
- package/dist/binding.browser.js +1 -1
- package/dist/binding.d.ts +1 -1
- package/dist/binding.js +1 -1
- package/dist/byte-writer.d.ts +0 -18
- package/dist/byte-writer.js +6 -30
- package/dist/child-stub.d.ts +0 -17
- package/dist/child-stub.js +6 -22
- package/dist/command-buffer.d.ts +5 -26
- package/dist/command-buffer.js +28 -39
- package/dist/compile-options.d.ts +11 -0
- package/dist/compile-options.js +99 -0
- package/dist/compile-types.d.ts +330 -0
- package/dist/compile-types.js +1 -0
- package/dist/compile.d.ts +22 -328
- package/dist/compile.js +129 -379
- package/dist/directive-types.d.ts +1 -0
- package/dist/directive-types.js +1 -6
- package/dist/generated/arena-layout.d.ts +6 -4
- package/dist/generated/arena-layout.js +6 -7
- package/dist/generated/fused-wire.d.ts +3 -0
- package/dist/generated/fused-wire.js +229 -0
- package/dist/generated/parse-options.js +0 -5
- package/dist/generated/wire-constants.d.ts +3 -0
- package/dist/generated/wire-constants.js +33 -42
- package/dist/handles.d.ts +0 -7
- package/dist/hast/child-stub.d.ts +1 -8
- package/dist/hast/child-stub.js +14 -13
- package/dist/hast/element-props.d.ts +13 -0
- package/dist/hast/element-props.js +52 -6
- package/dist/hast/generated/node-types.d.ts +1 -9
- package/dist/hast/generated/node-types.js +1 -9
- package/dist/hast/generated/walk-decode.d.ts +10 -0
- package/dist/hast/generated/walk-decode.js +61 -0
- package/dist/hast/hast-materializer.d.ts +3 -10
- package/dist/hast/hast-materializer.js +73 -47
- package/dist/hast/hast-reader.d.ts +9 -38
- package/dist/hast/hast-reader.js +82 -271
- package/dist/hast/hast-visitor.d.ts +29 -16
- package/dist/hast/hast-visitor.js +197 -508
- package/dist/hast/hast-walk.d.ts +18 -0
- package/dist/hast/hast-walk.js +264 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -12
- package/dist/lazy-child-resolver.d.ts +1 -21
- package/dist/lazy-child-resolver.js +11 -32
- package/dist/materializer-cache.d.ts +5 -29
- package/dist/materializer-cache.js +29 -101
- package/dist/mdast/child-stub.d.ts +1 -12
- package/dist/mdast/child-stub.js +18 -28
- package/dist/mdast/column-align.d.ts +1 -1
- package/dist/mdast/column-align.js +0 -2
- package/dist/mdast/generated/layout.d.ts +0 -16
- package/dist/mdast/generated/layout.js +6 -47
- package/dist/mdast/generated/node-types.d.ts +1 -9
- package/dist/mdast/generated/node-types.js +3 -9
- package/dist/mdast/mdast-materializer.d.ts +3 -11
- package/dist/mdast/mdast-materializer.js +91 -63
- package/dist/mdast/mdast-reader.d.ts +15 -63
- package/dist/mdast/mdast-reader.js +132 -269
- package/dist/mdast/mdast-visitor.d.ts +23 -15
- package/dist/mdast/mdast-visitor.js +188 -294
- package/dist/mdast/mdast-walk.d.ts +13 -0
- package/dist/mdast/mdast-walk.js +144 -0
- package/dist/mdx-attr.js +0 -3
- package/dist/mdx-types.js +1 -6
- package/dist/op-stream.d.ts +1 -15
- package/dist/op-stream.js +3 -19
- package/dist/phantom.d.ts +0 -1
- package/dist/phantom.js +1 -9
- package/dist/plugin-pipeline.d.ts +32 -0
- package/dist/plugin-pipeline.js +177 -0
- package/dist/plugin.d.ts +8 -7
- package/dist/plugin.js +3 -9
- package/dist/types.d.ts +0 -1
- package/dist/visitor-node.d.ts +12 -0
- package/dist/visitor-node.js +23 -0
- package/dist/visitor-shared.d.ts +26 -30
- package/dist/visitor-shared.js +34 -36
- package/dist/wire-read.d.ts +0 -22
- package/dist/wire-read.js +3 -24
- package/index.d.ts +19 -10
- package/index.js +56 -53
- package/package.json +3 -12
- package/dist/string-pool.d.ts +0 -13
- package/dist/string-pool.js +0 -91
package/dist/compile.d.ts
CHANGED
|
@@ -1,288 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
type
|
|
6
|
-
type NativeCompileOptions = {
|
|
7
|
-
parseOptions: number;
|
|
8
|
-
convertOptions: NativeConvertOptions | undefined;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Split the user-facing `Features` into the packed parser options plus the
|
|
12
|
-
* conversion-side `JsConvertOptions` carrying the footnote i18n strings and the
|
|
13
|
-
* raw-HTML reparse. The public API only exposes `features`; both halves are
|
|
14
|
-
* routed to napi internally.
|
|
15
|
-
*/
|
|
16
|
-
export declare function featuresToNative(features: Features | undefined): NativeCompileOptions;
|
|
17
|
-
/** Configuration for static subtree collapsing during MDX compilation. */
|
|
18
|
-
export interface OptimizeStaticConfig {
|
|
19
|
-
component: string;
|
|
20
|
-
prop: string;
|
|
21
|
-
wrapPropValue?: boolean;
|
|
22
|
-
ignoreElements?: string[];
|
|
23
|
-
}
|
|
24
|
-
/** Granular smart-punctuation toggles. Omitted fields default to true. */
|
|
25
|
-
export interface SmartPunctuationOptions {
|
|
26
|
-
/** Replace straight quotes with curly/smart quotes. Default: true. */
|
|
27
|
-
quotes?: boolean;
|
|
28
|
-
/** Replace `--`/`---` with en-dash/em-dash. Default: true. */
|
|
29
|
-
dashes?: boolean;
|
|
30
|
-
/** Replace `...` with ellipsis (`…`). Default: true. */
|
|
31
|
-
ellipses?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Per-backref callback. Invoked once per anchor in the footnotes section
|
|
35
|
-
* with 1-based `referenceNumber` and `rerunIndex` (1 on the first backref
|
|
36
|
-
* to that definition, 2 on the second, and so on). Must return the final
|
|
37
|
-
* string used as the backref content or `aria-label`.
|
|
38
|
-
*/
|
|
39
|
-
export type FootnoteBackrefCallback = (referenceNumber: number, rerunIndex: number) => string;
|
|
40
|
-
/**
|
|
41
|
-
* i18n strings for the GFM footnotes section. Mirrors `footnoteLabel`,
|
|
42
|
-
* `footnoteBackLabel`, and `footnoteBackContent` from remark-rehype.
|
|
43
|
-
*
|
|
44
|
-
* `backContent` and `backLabel` each accept either a template string with
|
|
45
|
-
* the `{reference}` placeholder (substituted with `1` or `1-2` to match
|
|
46
|
-
* remark-rehype's default suffix), or a callback receiving the raw
|
|
47
|
-
* `(referenceNumber, rerunIndex)` pair.
|
|
48
|
-
*
|
|
49
|
-
* Passing this object enables footnotes. To turn them off, use
|
|
50
|
-
* `gfm: { footnotes: false }`.
|
|
51
|
-
*/
|
|
52
|
-
export interface FootnoteOptions {
|
|
53
|
-
/** `<h2>` label opening the footnotes section. Default: `"Footnotes"`. */
|
|
54
|
-
label?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Backref `<a>` content. Default: `"↩"`.
|
|
57
|
-
*
|
|
58
|
-
* Template form: the string is used as-is, and a `<sup>K</sup>` marker
|
|
59
|
-
* is auto-appended on reruns (k > 1). Callback form: returns the full
|
|
60
|
-
* content for each backref; no auto-sup is added.
|
|
61
|
-
*/
|
|
62
|
-
backContent?: string | FootnoteBackrefCallback;
|
|
63
|
-
/**
|
|
64
|
-
* Backref `aria-label`. Default: `"Back to reference {reference}"`.
|
|
65
|
-
*
|
|
66
|
-
* Template form: `{reference}` becomes `n` for the first backref, `n-K`
|
|
67
|
-
* for subsequent ones. Callback form: returns the `aria-label` string
|
|
68
|
-
* for each backref.
|
|
69
|
-
*/
|
|
70
|
-
backLabel?: string | FootnoteBackrefCallback;
|
|
71
|
-
/** Prefix applied to footnote IDs to prevent DOM clobbering. Default: `"user-content-"`. */
|
|
72
|
-
clobberPrefix?: string;
|
|
73
|
-
}
|
|
74
|
-
/** Granular GFM toggles, nested under {@link Features.gfm}. */
|
|
75
|
-
export interface GfmOptions {
|
|
76
|
-
/**
|
|
77
|
-
* Enable GFM footnotes (`[^id]`). Default: true.
|
|
78
|
-
*
|
|
79
|
-
* Pass `false` to drop footnote parsing while keeping the rest of GFM;
|
|
80
|
-
* pass an object to enable footnotes with custom i18n strings (see
|
|
81
|
-
* {@link FootnoteOptions}).
|
|
82
|
-
*/
|
|
83
|
-
footnotes?: boolean | FootnoteOptions;
|
|
84
|
-
}
|
|
85
|
-
/** Granular math toggles, nested under {@link Features.math}. */
|
|
86
|
-
export interface MathOptions {
|
|
87
|
-
/**
|
|
88
|
-
* Treat single-dollar runs (`$ ... $`) as inline math. Default: true.
|
|
89
|
-
*
|
|
90
|
-
* Set `false` to keep single `$` as literal text while still parsing
|
|
91
|
-
* `$$ ... $$` display math. Mirrors `singleDollarTextMath` from
|
|
92
|
-
* remark-math.
|
|
93
|
-
*/
|
|
94
|
-
singleDollarTextMath?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/** Parser feature toggles. All default to their documented value when omitted. */
|
|
97
|
-
export interface Features {
|
|
98
|
-
/**
|
|
99
|
-
* GFM: tables, footnotes, strikethrough, task lists. Default: true.
|
|
100
|
-
*
|
|
101
|
-
* Pass an options object for granular control:
|
|
102
|
-
* ```ts
|
|
103
|
-
* gfm: { footnotes: false } // skip footnotes only
|
|
104
|
-
* gfm: { footnotes: { label: "Notes" } } // localize footnotes
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
gfm?: boolean | GfmOptions;
|
|
108
|
-
/** Frontmatter: YAML (`--- ... ---`) and TOML (`+++ ... +++`). Default: true. */
|
|
109
|
-
frontmatter?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Math blocks and inline math. Default: false.
|
|
112
|
-
*
|
|
113
|
-
* Pass an options object for granular control:
|
|
114
|
-
* ```ts
|
|
115
|
-
* math: { singleDollarTextMath: false } // $$..$$ only, $..$ literal
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
math?: boolean | MathOptions;
|
|
119
|
-
/** Heading attributes (`# text { #id .class }`). Default: false. */
|
|
120
|
-
headingAttributes?: boolean;
|
|
121
|
-
/** Colon-delimited container directive blocks (`:::`). Default: false. */
|
|
122
|
-
directive?: boolean;
|
|
123
|
-
/** Superscript (`^super^`). Default: false. */
|
|
124
|
-
superscript?: boolean;
|
|
125
|
-
/** Subscript (`~sub~`). Default: false. */
|
|
126
|
-
subscript?: boolean;
|
|
127
|
-
/** Obsidian-style wikilinks (`[[link]]`). Default: false. */
|
|
128
|
-
wikilinks?: boolean;
|
|
129
|
-
/** Definition lists (a term line then a `: definition`). Default: false. */
|
|
130
|
-
definitionList?: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Smart punctuation à la SmartyPants. Default: false.
|
|
133
|
-
*
|
|
134
|
-
* Pass `true` to enable all categories, or an options object for granular control:
|
|
135
|
-
* ```ts
|
|
136
|
-
* smartPunctuation: { dashes: false } // quotes + ellipses only
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
smartPunctuation?: boolean | SmartPunctuationOptions;
|
|
140
|
-
/**
|
|
141
|
-
* Parse raw HTML embedded in Markdown into real HAST element nodes.
|
|
142
|
-
* Default: false.
|
|
143
|
-
*
|
|
144
|
-
* By default, inline and block HTML is kept as opaque `raw` nodes
|
|
145
|
-
* (re-emitted verbatim on stringify). With `rawHtml: true`, the tree is
|
|
146
|
-
* reparsed so raw HTML becomes structured `element`/`text`/`comment` nodes
|
|
147
|
-
* with normalized properties, including tags that open in one raw block
|
|
148
|
-
* and close in another. Positions are not preserved through the reparse.
|
|
149
|
-
*/
|
|
150
|
-
rawHtml?: boolean;
|
|
151
|
-
}
|
|
152
|
-
export interface CompileOptions {
|
|
153
|
-
/** MDAST plugins, in run order. A nested array runs its own plugins, in
|
|
154
|
-
* their own order, at the array's position. */
|
|
155
|
-
mdastPlugins?: MdastPluginList;
|
|
156
|
-
/** HAST plugins, in run order. Nests like `mdastPlugins`. */
|
|
157
|
-
hastPlugins?: HastPluginList;
|
|
158
|
-
features?: Features;
|
|
159
|
-
/**
|
|
160
|
-
* The document being processed, surfaced to plugins as `ctx.fileURL`. Must
|
|
161
|
-
* be a `URL` (e.g. Astro's `fileURL`); convert a filesystem path with Node's
|
|
162
|
-
* `pathToFileURL` before passing it.
|
|
163
|
-
*/
|
|
164
|
-
fileURL?: URL;
|
|
165
|
-
/**
|
|
166
|
-
* Initial document-level data bag, seeding `ctx.data` before any plugin runs.
|
|
167
|
-
* It is the same object plugins mutate and the caller reads back as
|
|
168
|
-
* `result.data`, so values flow both into and out of a compile. Defaults to a
|
|
169
|
-
* fresh empty object. Used by reference and mutated in place, so pass a
|
|
170
|
-
* throwaway object per compile rather than a shared one.
|
|
171
|
-
*/
|
|
172
|
-
data?: Data;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* JS/JSX output options, accepted by both {@link mdxToJs} and
|
|
176
|
-
* {@link markdownToJs}. Exported on its own so wrappers can expose the codegen
|
|
177
|
-
* knobs without the shared pipeline fields.
|
|
178
|
-
*/
|
|
179
|
-
export interface MdxOnlyOptions {
|
|
180
|
-
optimizeStatic?: OptimizeStaticConfig;
|
|
181
|
-
/** Place to import automatic JSX runtimes from (e.g. "react", "preact"). Default: "react". */
|
|
182
|
-
jsxImportSource?: string;
|
|
183
|
-
/** Whether to keep JSX instead of compiling it to functions. Default: false. */
|
|
184
|
-
jsx?: boolean;
|
|
185
|
-
/** JSX runtime: "automatic" (default) or "classic". */
|
|
186
|
-
jsxRuntime?: "automatic" | "classic";
|
|
187
|
-
/** Enable development mode. Default: false. */
|
|
188
|
-
development?: boolean;
|
|
189
|
-
/** Place to import the component provider from. */
|
|
190
|
-
providerImportSource?: string;
|
|
191
|
-
/** Pragma for JSX in classic runtime (default: "React.createElement"). */
|
|
192
|
-
pragma?: string;
|
|
193
|
-
/** Pragma for JSX fragments in classic runtime (default: "React.Fragment"). */
|
|
194
|
-
pragmaFrag?: string;
|
|
195
|
-
/** Where to import the pragma from in classic runtime (default: "react"). */
|
|
196
|
-
pragmaImportSource?: string;
|
|
197
|
-
/**
|
|
198
|
-
* Output format: "program" (default) or "function-body".
|
|
199
|
-
*
|
|
200
|
-
* - `"program"`: ES module with `import`/`export` statements.
|
|
201
|
-
* - `"function-body"`: Function body that reads runtime from `arguments[0]`
|
|
202
|
-
* and returns `{ default: MDXContent, ...exports }`. Suitable for
|
|
203
|
-
* `new Function()` or `evaluate()`.
|
|
204
|
-
*/
|
|
205
|
-
outputFormat?: "program" | "function-body";
|
|
206
|
-
/**
|
|
207
|
-
* Casing for HTML/SVG attribute names on plain (rehype-produced) elements.
|
|
208
|
-
*
|
|
209
|
-
* - `"react"` (default): `className`, `htmlFor`, `strokeLinecap`, `xmlLang`.
|
|
210
|
-
* - `"html"`: `class`, `for`, `stroke-linecap`, `xml:lang`.
|
|
211
|
-
*
|
|
212
|
-
* Does not affect attributes on user-written MDX JSX; those are emitted as
|
|
213
|
-
* the author wrote them.
|
|
214
|
-
*/
|
|
215
|
-
elementAttributeNameCase?: "react" | "html";
|
|
216
|
-
/**
|
|
217
|
-
* Casing for keys in `style` objects parsed from `style="…"` strings on
|
|
218
|
-
* plain (rehype-produced) elements.
|
|
219
|
-
*
|
|
220
|
-
* - `"dom"` (default): `{backgroundColor: …, WebkitLineClamp: …}`.
|
|
221
|
-
* - `"css"`: `{"background-color": …, "-webkit-line-clamp": …}`.
|
|
222
|
-
*/
|
|
223
|
-
stylePropertyNameCase?: "dom" | "css";
|
|
224
|
-
}
|
|
225
|
-
export interface MdxCompileOptions extends CompileOptions, MdxOnlyOptions {
|
|
226
|
-
}
|
|
227
|
-
export interface MarkdownToJsOptions extends CompileOptions, MdxOnlyOptions {
|
|
228
|
-
}
|
|
229
|
-
/** Frontmatter block extracted from the parsed Markdown/MDX source. */
|
|
230
|
-
export interface Frontmatter {
|
|
231
|
-
/** Delimiter syntax used for the block. */
|
|
232
|
-
kind: "yaml" | "toml";
|
|
233
|
-
/** Raw content between the delimiters (`---`/`+++` lines excluded). */
|
|
234
|
-
value: string;
|
|
235
|
-
}
|
|
236
|
-
/** Result of {@link markdownToHtml}. */
|
|
237
|
-
export interface MarkdownToHtmlResult {
|
|
238
|
-
/** Rendered HTML string. */
|
|
239
|
-
html: string;
|
|
240
|
-
/** Frontmatter block at the start of the document, or `null` if none. */
|
|
241
|
-
frontmatter: Frontmatter | null;
|
|
242
|
-
/** Document-level data bag shared with plugins via `ctx.data`; the seeded `data` option if provided, else a fresh `{}`. */
|
|
243
|
-
data: Data;
|
|
244
|
-
}
|
|
245
|
-
/** Result of {@link mdxToJs}. */
|
|
246
|
-
export interface MdxToJsResult {
|
|
247
|
-
/** Compiled JavaScript module source. */
|
|
248
|
-
code: string;
|
|
249
|
-
/** Frontmatter block at the start of the document, or `null` if none. */
|
|
250
|
-
frontmatter: Frontmatter | null;
|
|
251
|
-
/** Document-level data bag shared with plugins via `ctx.data`; the seeded `data` option if provided, else a fresh `{}`. */
|
|
252
|
-
data: Data;
|
|
253
|
-
}
|
|
254
|
-
/** Result of {@link markdownToJs}. */
|
|
255
|
-
export interface MarkdownToJsResult {
|
|
256
|
-
/** Compiled JavaScript module source. */
|
|
257
|
-
code: string;
|
|
258
|
-
/** Frontmatter block at the start of the document, or `null` if none. */
|
|
259
|
-
frontmatter: Frontmatter | null;
|
|
260
|
-
/** Document-level data bag shared with plugins via `ctx.data`; the seeded `data` option if provided, else a fresh `{}`. */
|
|
261
|
-
data: Data;
|
|
262
|
-
}
|
|
263
|
-
type CombineAsync<A> = "async" extends A ? "async" : "maybe" extends A ? "maybe" : "sync";
|
|
264
|
-
type AnyFn = (...args: any[]) => unknown;
|
|
265
|
-
type ReturnsPromise<F> = F extends AnyFn ? [Extract<ReturnType<F>, Promise<unknown>>] extends [never] ? "sync" : [Exclude<ReturnType<F>, Promise<unknown>>] extends [never] ? "async" : "maybe" : "sync";
|
|
266
|
-
type FieldIsAsync<V> = V extends AnyFn ? ReturnsPromise<V> : V extends {
|
|
267
|
-
visit: infer F;
|
|
268
|
-
} ? ReturnsPromise<F> : V extends ReadonlyArray<infer Item> ? Item extends {
|
|
269
|
-
visit: infer F;
|
|
270
|
-
} ? ReturnsPromise<F> : "sync" : "sync";
|
|
271
|
-
type AnyVisitorAsync<P> = {
|
|
272
|
-
[K in keyof P]-?: FieldIsAsync<NonNullable<P[K]>>;
|
|
273
|
-
}[keyof P];
|
|
274
|
-
type IsPluginAsync<P> = P extends unknown ? CombineAsync<AnyVisitorAsync<P>> : never;
|
|
275
|
-
type ResolveInput<P, D extends readonly unknown[] = [0, 0, 0, 0, 0, 0, 0, 0]> = D extends readonly [
|
|
276
|
-
unknown,
|
|
277
|
-
...infer Rest
|
|
278
|
-
] ? P extends ReadonlyArray<infer Item> ? ResolveInput<Item, Rest> : P extends (...args: never[]) => infer Def ? ResolveInput<Def, Rest> : P : never;
|
|
279
|
-
type AnyInputAsync<Ps> = Ps extends ReadonlyArray<infer P> ? CombineAsync<IsPluginAsync<ResolveInput<P>>> : "sync";
|
|
280
|
-
type OptionsAsync<O extends CompileOptions> = CombineAsync<AnyInputAsync<NonNullable<O["mdastPlugins"]>> | AnyInputAsync<NonNullable<O["hastPlugins"]>>>;
|
|
281
|
-
type ResultFor<O extends CompileOptions, R> = {
|
|
282
|
-
sync: R;
|
|
283
|
-
async: Promise<R>;
|
|
284
|
-
maybe: R | Promise<R>;
|
|
285
|
-
}[OptionsAsync<O>];
|
|
1
|
+
import type { Root } from "mdast";
|
|
2
|
+
import type { CompileOptions, EvaluateOptions, HastTreeOptions, HtmlToHastOptions, MarkdownToHtmlResult, MarkdownToJsOptions, MarkdownToJsResult, MdastTreeOptions, MdxCompileOptions, MdxToJsResult, ResultFor } from "./compile-types.js";
|
|
3
|
+
export { DEFAULT_PARSE_OPTIONS, featuresToNative } from "./compile-options.js";
|
|
4
|
+
export type { CompileOptions, EvaluateOptions, Features, FootnoteBackrefCallback, FootnoteOptions, Frontmatter, GfmOptions, HastTreeOptions, HtmlToHastOptions, MarkdownToHtmlResult, MarkdownToJsOptions, MarkdownToJsResult, MathOptions, MdastTreeOptions, MdxCompileOptions, MdxOnlyOptions, MdxToJsResult, OptimizeStaticConfig, SmartPunctuationOptions, TreeOptions, } from "./compile-types.js";
|
|
5
|
+
import type { HastNode } from "./types.js";
|
|
286
6
|
export declare function markdownToHtml(source: string): MarkdownToHtmlResult;
|
|
287
7
|
export declare function markdownToHtml<O extends CompileOptions>(source: string, options?: O): ResultFor<O, MarkdownToHtmlResult>;
|
|
288
8
|
export declare function mdxToJs(source: string): MdxToJsResult;
|
|
@@ -295,13 +15,6 @@ export declare function mdxToJs<O extends MdxCompileOptions>(source: string, opt
|
|
|
295
15
|
*/
|
|
296
16
|
export declare function markdownToJs(source: string): MarkdownToJsResult;
|
|
297
17
|
export declare function markdownToJs<O extends MarkdownToJsOptions>(source: string, options?: O): ResultFor<O, MarkdownToJsResult>;
|
|
298
|
-
export interface EvaluateOptions extends Omit<MdxCompileOptions, "jsx" | "outputFormat"> {
|
|
299
|
-
Fragment: unknown;
|
|
300
|
-
jsx: (type: unknown, props: unknown, key?: unknown) => unknown;
|
|
301
|
-
jsxs: (type: unknown, props: unknown, key?: unknown) => unknown;
|
|
302
|
-
jsxDEV?: (type: unknown, props: unknown, key: unknown, isStaticChildren: boolean, source: unknown, self: unknown) => unknown;
|
|
303
|
-
useMDXComponents?: () => Record<string, unknown>;
|
|
304
|
-
}
|
|
305
18
|
/**
|
|
306
19
|
* Compile and evaluate MDX in one step.
|
|
307
20
|
*
|
|
@@ -314,45 +27,18 @@ export interface EvaluateOptions extends Omit<MdxCompileOptions, "jsx" | "output
|
|
|
314
27
|
* ```
|
|
315
28
|
*/
|
|
316
29
|
export declare function evaluate(source: string, options: EvaluateOptions): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
317
|
-
/** Options for the step-by-step tree functions. */
|
|
318
|
-
export interface TreeOptions {
|
|
319
|
-
features?: Features;
|
|
320
|
-
/**
|
|
321
|
-
* Record `position` on every node. Default: `true`.
|
|
322
|
-
*
|
|
323
|
-
* A unist position is three objects per node and roughly half a materialized
|
|
324
|
-
* tree's memory, on top of the parser's line-index build. Pass `false` when
|
|
325
|
-
* nothing downstream reads `node.position`.
|
|
326
|
-
*/
|
|
327
|
-
position?: boolean;
|
|
328
|
-
}
|
|
329
30
|
/** Parse Markdown source into a materialized mdast tree. */
|
|
330
|
-
export declare function markdownToMdast(source: string
|
|
31
|
+
export declare function markdownToMdast(source: string): Root;
|
|
32
|
+
export declare function markdownToMdast<O extends MdastTreeOptions>(source: string, options?: O): ResultFor<O, Root>;
|
|
331
33
|
/** Parse MDX source into a materialized mdast tree. */
|
|
332
|
-
export declare function mdxToMdast(source: string
|
|
34
|
+
export declare function mdxToMdast(source: string): Root;
|
|
35
|
+
export declare function mdxToMdast<O extends MdastTreeOptions>(source: string, options?: O): ResultFor<O, Root>;
|
|
333
36
|
/** Convert Markdown source to a materialized hast tree. */
|
|
334
|
-
export declare function markdownToHast(source: string
|
|
37
|
+
export declare function markdownToHast(source: string): HastNode;
|
|
38
|
+
export declare function markdownToHast<O extends HastTreeOptions>(source: string, options?: O): ResultFor<O, HastNode>;
|
|
335
39
|
/** Convert MDX source to a materialized hast tree. */
|
|
336
|
-
export declare function mdxToHast(source: string
|
|
337
|
-
export
|
|
338
|
-
/**
|
|
339
|
-
* Parse as a fragment, so the returned `root` holds the string's own
|
|
340
|
-
* top-level nodes instead of an implied `<html>`/`<head>`/`<body>`.
|
|
341
|
-
*
|
|
342
|
-
* @default false
|
|
343
|
-
*/
|
|
344
|
-
fragment?: boolean;
|
|
345
|
-
/**
|
|
346
|
-
* The namespace a fragment's own top-level content parses in. `"svg"` reads
|
|
347
|
-
* it as foreign content, so `<circle />` self-closes and lands in the SVG
|
|
348
|
-
* namespace instead of being treated as an unknown HTML element.
|
|
349
|
-
*
|
|
350
|
-
* Ignored without `fragment: true`: a document always starts in HTML.
|
|
351
|
-
*
|
|
352
|
-
* @default "html"
|
|
353
|
-
*/
|
|
354
|
-
space?: "html" | "svg";
|
|
355
|
-
}
|
|
40
|
+
export declare function mdxToHast(source: string): HastNode;
|
|
41
|
+
export declare function mdxToHast<O extends HastTreeOptions>(source: string, options?: O): ResultFor<O, HastNode>;
|
|
356
42
|
/**
|
|
357
43
|
* Parse an HTML string into a materialized hast tree: a `root` whose children
|
|
358
44
|
* are the doctype (if any) and the implied `<html>` subtree, or the string's
|
|
@@ -360,4 +46,12 @@ export interface HtmlToHastOptions {
|
|
|
360
46
|
* include the `from-html` feature.
|
|
361
47
|
*/
|
|
362
48
|
export declare function htmlToHast(html: string, options?: HtmlToHastOptions): HastNode;
|
|
363
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Serialize a HAST tree to an HTML string: a `root` renders its children, any
|
|
51
|
+
* other node renders itself, and a list renders in order. MDX nodes have no
|
|
52
|
+
* HTML representation and are skipped; `raw` nodes are emitted verbatim.
|
|
53
|
+
*
|
|
54
|
+
* The result is the tree's exact serialization, with no trailing newline (the
|
|
55
|
+
* one `markdownToHtml` ends its document with).
|
|
56
|
+
*/
|
|
57
|
+
export declare function hastToHtml(tree: HastNode | readonly HastNode[]): string;
|