satteri 0.10.0 → 0.10.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/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. Only available
324
- * in builds that include the `from-html` feature.
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. Only available
590
- * in builds that include the `from-html` feature.
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,5 +1,5 @@
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";
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.0",
3
+ "version": "0.10.1",
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.0",
92
- "@bruits/satteri-linux-arm64-gnu": "0.10.0",
93
- "@bruits/satteri-linux-x64-musl": "0.10.0",
94
- "@bruits/satteri-linux-arm64-musl": "0.10.0",
95
- "@bruits/satteri-darwin-x64": "0.10.0",
96
- "@bruits/satteri-darwin-arm64": "0.10.0",
97
- "@bruits/satteri-win32-x64-msvc": "0.10.0",
98
- "@bruits/satteri-win32-arm64-msvc": "0.10.0",
99
- "@bruits/satteri-wasm32-wasi": "0.10.0"
91
+ "@bruits/satteri-linux-x64-gnu": "0.10.1",
92
+ "@bruits/satteri-linux-arm64-gnu": "0.10.1",
93
+ "@bruits/satteri-linux-x64-musl": "0.10.1",
94
+ "@bruits/satteri-linux-arm64-musl": "0.10.1",
95
+ "@bruits/satteri-darwin-x64": "0.10.1",
96
+ "@bruits/satteri-darwin-arm64": "0.10.1",
97
+ "@bruits/satteri-win32-x64-msvc": "0.10.1",
98
+ "@bruits/satteri-win32-arm64-msvc": "0.10.1",
99
+ "@bruits/satteri-wasm32-wasi": "0.10.1"
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",