@jxsuite/parser 0.35.0 → 1.0.0

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/src/md-html.ts CHANGED
@@ -1,49 +1,12 @@
1
1
  /**
2
- * Md-html — browser-safe markdown → sanitized HTML string
2
+ * Md-html — compatibility shim.
3
3
  *
4
- * Small display pipeline for rendering untrusted markdown (e.g. LLM chat output) as
5
- * HTML: remark-parse + remark-gfm → remark-rehype (raw HTML disabled) → rehype-sanitize
6
- * (default schema: strips scripts, event handlers, javascript:/data: URLs) → stringify.
7
- *
8
- * Unlike `./md.ts` this module has no node-only imports, so it is safe for the studio
9
- * bundle. It intentionally produces an HTML *string*, not Jx nodes — use
10
- * `@jxsuite/parser/markdown` for markdown → Jx document transpilation.
4
+ * The browser-safe markdown → sanitized HTML pipeline moved to `@jxsuite/markup/md-html`;
5
+ * this module re-exports it so the parser's historical `@jxsuite/parser/md-html`
6
+ * entrypoint keeps working for downstream consumers.
11
7
  *
12
8
  * @module @jxsuite/parser/md-html
13
9
  * @license MIT
14
10
  */
15
11
 
16
- import rehypeSanitize from "rehype-sanitize";
17
- import rehypeStringify from "rehype-stringify";
18
- import remarkGfm from "remark-gfm";
19
- import remarkParse from "remark-parse";
20
- import remarkRehype from "remark-rehype";
21
- import { unified } from "unified";
22
-
23
- /**
24
- * Minimal structural surface of the unified processor used here — same rationale as
25
- * `UnifiedProcessor` in ./types.ts (oxlint sees the ESM-only unified types as `any`), plus
26
- * `processSync` which the shared type doesn't carry.
27
- */
28
- interface MdHtmlProcessor {
29
- use: (plugin: unknown, ...options: unknown[]) => MdHtmlProcessor;
30
- processSync: (source: string) => { toString: () => string };
31
- }
32
-
33
- const processor = (unified as unknown as () => MdHtmlProcessor)()
34
- .use(remarkParse)
35
- .use(remarkGfm)
36
- .use(remarkRehype)
37
- .use(rehypeSanitize)
38
- .use(rehypeStringify);
39
-
40
- /**
41
- * Convert markdown source to a sanitized HTML string (GFM tables/strikethrough/task lists
42
- * supported). Raw HTML in the source is dropped, not passed through.
43
- *
44
- * @param {string} markdown
45
- * @returns {string}
46
- */
47
- export function markdownToHtml(markdown: string): string {
48
- return String(processor.processSync(markdown));
49
- }
12
+ export { markdownToHtml } from "@jxsuite/markup/md-html";
package/src/serialize.ts CHANGED
@@ -24,7 +24,7 @@ import remarkStringify from "remark-stringify";
24
24
  import remarkDirective from "remark-directive";
25
25
  import remarkGfm from "remark-gfm";
26
26
  import { stringify as stringifyYaml } from "yaml";
27
- import { htmlToJx } from "./html-to-jx.ts";
27
+ import { htmlToJx } from "@jxsuite/markup/html-to-jx";
28
28
  import { expandDotPaths } from "./transpile.ts";
29
29
  import type {
30
30
  JsonValue,
package/src/transpile.ts CHANGED
@@ -17,11 +17,11 @@ import remarkFrontmatter from "remark-frontmatter";
17
17
  import remarkParseFrontmatter from "remark-parse-frontmatter";
18
18
  import remarkGfm from "remark-gfm";
19
19
  import remarkDirective from "remark-directive";
20
- import { htmlToJx } from "./html-to-jx.ts";
20
+ import { htmlToJx } from "@jxsuite/markup/html-to-jx";
21
21
  import type { MdastNode, UnifiedProcessor } from "./types.ts";
22
22
  import type { JsonValue, JxAttributeValue, JxDocument, JxElement } from "@jxsuite/schema/types";
23
23
 
24
- export { htmlToJx } from "./html-to-jx.ts";
24
+ export { htmlToJx } from "@jxsuite/markup/html-to-jx";
25
25
 
26
26
  // ─── Dot-path expansion ─────────────────────────────────────────────────────
27
27
 
package/src/types.ts CHANGED
@@ -1,4 +1,8 @@
1
- import type { JxElement } from "@jxsuite/schema/types";
1
+ import type { JxElement, TocEntry } from "@jxsuite/schema/types";
2
+
3
+ // The content wire types are core (extensions implement them, hosts thread them); re-exported here
4
+ // So parser-internal modules and downstream consumers keep their historical import path.
5
+ export type { ContentLoaderEntry, TocEntry } from "@jxsuite/schema/types";
2
6
 
3
7
  export interface MarkdownFileResult {
4
8
  slug: string;
@@ -12,25 +16,18 @@ export interface MarkdownFileResult {
12
16
  [key: string]: unknown;
13
17
  }
14
18
 
15
- export interface TocEntry {
16
- depth: number;
17
- text: string;
18
- id: string;
19
- }
20
-
21
19
  export type ContentEntry = MarkdownFileResult & Record<string, unknown>;
22
20
 
23
- export interface ContentLoaderEntry {
24
- id: string;
25
- data: Record<string, unknown>;
26
- body: string | null;
27
- $children?: (JxElement | string)[];
28
- _meta?: {
29
- excerpt?: string;
30
- toc?: TocEntry[];
31
- readingTime?: number;
32
- wordCount?: number;
33
- };
21
+ /**
22
+ * A content-type definition in the project.json `content` section — the parser extension owns this
23
+ * shape (its project fragment schema is the validation source of truth).
24
+ */
25
+ export interface ContentTypeDef {
26
+ source?: string;
27
+ format?: string;
28
+ schema?: Record<string, unknown>;
29
+ $elements?: (string | { $ref: string })[];
30
+ [key: string]: unknown;
34
31
  }
35
32
 
36
33
  export interface MdastNode {