satteri 0.10.0 → 0.10.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/dist/compile.d.ts +23 -3
- package/dist/compile.js +5 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +3 -2
- package/index.d.ts +4 -1
- package/package.json +10 -10
package/dist/compile.d.ts
CHANGED
|
@@ -318,10 +318,30 @@ export declare function mdxToMdast(source: string, options?: TreeOptions): Mdast
|
|
|
318
318
|
export declare function markdownToHast(source: string, options?: TreeOptions): HastNode;
|
|
319
319
|
/** Convert MDX source to a materialized hast tree. */
|
|
320
320
|
export declare function mdxToHast(source: string, options?: TreeOptions): HastNode;
|
|
321
|
+
export interface HtmlToHastOptions {
|
|
322
|
+
/**
|
|
323
|
+
* Parse as a fragment, so the returned `root` holds the string's own
|
|
324
|
+
* top-level nodes instead of an implied `<html>`/`<head>`/`<body>`.
|
|
325
|
+
*
|
|
326
|
+
* @default false
|
|
327
|
+
*/
|
|
328
|
+
fragment?: boolean;
|
|
329
|
+
/**
|
|
330
|
+
* The namespace a fragment's own top-level content parses in. `"svg"` reads
|
|
331
|
+
* it as foreign content, so `<circle />` self-closes and lands in the SVG
|
|
332
|
+
* namespace instead of being treated as an unknown HTML element.
|
|
333
|
+
*
|
|
334
|
+
* Ignored without `fragment: true`: a document always starts in HTML.
|
|
335
|
+
*
|
|
336
|
+
* @default "html"
|
|
337
|
+
*/
|
|
338
|
+
space?: "html" | "svg";
|
|
339
|
+
}
|
|
321
340
|
/**
|
|
322
341
|
* Parse an HTML string into a materialized hast tree: a `root` whose children
|
|
323
|
-
* are the doctype (if any) and the implied `<html>` subtree
|
|
324
|
-
*
|
|
342
|
+
* are the doctype (if any) and the implied `<html>` subtree, or the string's
|
|
343
|
+
* own top-level nodes with `{ fragment: true }`. Only available in builds that
|
|
344
|
+
* include the `from-html` feature.
|
|
325
345
|
*/
|
|
326
|
-
export declare function htmlToHast(html: string): HastNode;
|
|
346
|
+
export declare function htmlToHast(html: string, options?: HtmlToHastOptions): HastNode;
|
|
327
347
|
export {};
|
package/dist/compile.js
CHANGED
|
@@ -586,11 +586,12 @@ export function mdxToHast(source, options = {}) {
|
|
|
586
586
|
}
|
|
587
587
|
/**
|
|
588
588
|
* Parse an HTML string into a materialized hast tree: a `root` whose children
|
|
589
|
-
* are the doctype (if any) and the implied `<html>` subtree
|
|
590
|
-
*
|
|
589
|
+
* are the doctype (if any) and the implied `<html>` subtree, or the string's
|
|
590
|
+
* own top-level nodes with `{ fragment: true }`. Only available in builds that
|
|
591
|
+
* include the `from-html` feature.
|
|
591
592
|
*/
|
|
592
|
-
export function htmlToHast(html) {
|
|
593
|
-
const handle = createHastHandleFromHtml(html);
|
|
593
|
+
export function htmlToHast(html, options = {}) {
|
|
594
|
+
const handle = createHastHandleFromHtml(html, options.fragment, options.space);
|
|
594
595
|
try {
|
|
595
596
|
return materializeHastTree(new HastReader(serializeHandle(handle)));
|
|
596
597
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { markdownToHtml, markdownToJs, mdxToJs, evaluate, markdownToMdast, mdxToMdast, markdownToHast, mdxToHast, htmlToHast, } from "./compile.js";
|
|
2
|
-
export type { CompileOptions, MdxCompileOptions, MdxOnlyOptions, MarkdownToJsOptions, EvaluateOptions, OptimizeStaticConfig, Features, TreeOptions, SmartPunctuationOptions, Frontmatter, MarkdownToHtmlResult, MarkdownToJsResult, MdxToJsResult, } from "./compile.js";
|
|
2
|
+
export type { CompileOptions, MdxCompileOptions, MdxOnlyOptions, MarkdownToJsOptions, EvaluateOptions, OptimizeStaticConfig, Features, TreeOptions, HtmlToHastOptions, SmartPunctuationOptions, Frontmatter, MarkdownToHtmlResult, MarkdownToJsResult, MdxToJsResult, } from "./compile.js";
|
|
3
3
|
export { defineMdastPlugin, defineHastPlugin } from "./plugin.js";
|
|
4
4
|
export type { MdastPluginDefinition, HastPluginDefinition, MdastPluginInput, HastPluginInput, MdastPluginEntry, HastPluginEntry, MdastPluginList, HastPluginList, PluginFactoryContext, } from "./plugin.js";
|
|
5
5
|
export type { HastVisitorInstance, HastVisitorContext, HastFilteredVisitor, HastContent, HastParentContent, RawHastContent, RawHtmlHastContent, EstreeProgram, } from "./hast/hast-visitor.js";
|
|
6
6
|
export type { MdastNode, HastNode, Custom, DataMap, Data, SourceFormat, Position, Point, MdxJsxAttributeNode, MdxJsxExpressionAttributeNode, MdxJsxAttributeValueExpressionNode, MdxJsxAttributeUnion, MdxJsxFlowElement, MdxJsxTextElement, MdxFlowExpression, MdxTextExpression, MdxjsEsm, MdxJsxFlowElementHast, MdxJsxTextElementHast, MdxFlowExpressionHast, MdxTextExpressionHast, MdxjsEsmHast, } from "./types.js";
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
7
|
+
export { normalizePlugins } from "./plugin.js";
|
|
8
|
+
export { visitMdastHandle, visitMdastHook, resolveMdastSubscriptions, } from "./mdast/mdast-visitor.js";
|
|
9
|
+
export type { MdastPluginInstance, MdastVisitorContext, MdastContent, MdastTarget, MdastParentContent, MdastDiagnostic, MdastHookFn, RawMdastContent, RawHtmlMdastContent, } from "./mdast/mdast-visitor.js";
|
|
10
|
+
export { visitHastHandle, visitHastHook, resolveSubscriptions as resolveHastSubscriptions, } from "./hast/hast-visitor.js";
|
|
11
|
+
export type { HastDiagnostic, HastHookFn } from "./hast/hast-visitor.js";
|
|
10
12
|
export { MdastReader } from "./mdast/mdast-reader.js";
|
|
11
13
|
export { materializeMdastTree } from "./mdast/mdast-materializer.js";
|
|
12
14
|
export { HastReader } from "./hast/hast-reader.js";
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,9 @@ export { markdownToHtml, markdownToJs, mdxToJs, evaluate, markdownToMdast, mdxTo
|
|
|
3
3
|
// Plugin definitions
|
|
4
4
|
export { defineMdastPlugin, defineHastPlugin } from "./plugin.js";
|
|
5
5
|
// Visitor pipeline (for manual plugin execution)
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export { normalizePlugins } from "./plugin.js";
|
|
7
|
+
export { visitMdastHandle, visitMdastHook, resolveMdastSubscriptions, } from "./mdast/mdast-visitor.js";
|
|
8
|
+
export { visitHastHandle, visitHastHook, resolveSubscriptions as resolveHastSubscriptions, } from "./hast/hast-visitor.js";
|
|
8
9
|
// Step-by-step API: readers, materializers, and handle functions
|
|
9
10
|
export { MdastReader } from "./mdast/mdast-reader.js";
|
|
10
11
|
export { materializeMdastTree } from "./mdast/mdast-materializer.js";
|
package/index.d.ts
CHANGED
|
@@ -79,9 +79,12 @@ export declare function createHastHandle(source: string, features?: JsFeatures |
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Parse an HTML string into structured HAST (elements, text, comments).
|
|
82
|
+
* Parses as a fragment when `fragment` is set, keeping the top-level nodes as
|
|
83
|
+
* they are instead of implying `<html>`/`<head>`/`<body>`. `space` picks the
|
|
84
|
+
* namespace a fragment's own top-level content parses in: "html" or "svg".
|
|
82
85
|
* Returns an opaque handle; the arena stays in Rust memory.
|
|
83
86
|
*/
|
|
84
|
-
export declare function createHastHandleFromHtml(html: string): HastHandle
|
|
87
|
+
export declare function createHastHandleFromHtml(html: string, fragment?: boolean | undefined | null, space?: string | undefined | null): HastHandle
|
|
85
88
|
|
|
86
89
|
/**
|
|
87
90
|
* Parse + frontmatter + HAST conversion in one crossing (HAST-plugin path
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "satteri",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "High-performance Markdown and MDX processing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -88,15 +88,15 @@
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"optionalDependencies": {
|
|
91
|
-
"@bruits/satteri-linux-x64-gnu": "0.10.
|
|
92
|
-
"@bruits/satteri-linux-arm64-gnu": "0.10.
|
|
93
|
-
"@bruits/satteri-linux-x64-musl": "0.10.
|
|
94
|
-
"@bruits/satteri-linux-arm64-musl": "0.10.
|
|
95
|
-
"@bruits/satteri-darwin-x64": "0.10.
|
|
96
|
-
"@bruits/satteri-darwin-arm64": "0.10.
|
|
97
|
-
"@bruits/satteri-win32-x64-msvc": "0.10.
|
|
98
|
-
"@bruits/satteri-win32-arm64-msvc": "0.10.
|
|
99
|
-
"@bruits/satteri-wasm32-wasi": "0.10.
|
|
91
|
+
"@bruits/satteri-linux-x64-gnu": "0.10.2",
|
|
92
|
+
"@bruits/satteri-linux-arm64-gnu": "0.10.2",
|
|
93
|
+
"@bruits/satteri-linux-x64-musl": "0.10.2",
|
|
94
|
+
"@bruits/satteri-linux-arm64-musl": "0.10.2",
|
|
95
|
+
"@bruits/satteri-darwin-x64": "0.10.2",
|
|
96
|
+
"@bruits/satteri-darwin-arm64": "0.10.2",
|
|
97
|
+
"@bruits/satteri-win32-x64-msvc": "0.10.2",
|
|
98
|
+
"@bruits/satteri-win32-arm64-msvc": "0.10.2",
|
|
99
|
+
"@bruits/satteri-wasm32-wasi": "0.10.2"
|
|
100
100
|
},
|
|
101
101
|
"scripts": {
|
|
102
102
|
"build:binary:wasm": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --release --esm --strip --target wasm32-wasip1-threads",
|