@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/dist/content-loader.js +271 -0
- package/dist/content.js +2 -2
- package/dist/markdown.js +2 -2
- package/dist/serialize.js +2 -2
- package/jx-extension.json +17 -0
- package/package.json +19 -16
- package/schemas/document.fragment.schema.json +27 -0
- package/schemas/project.fragment.schema.json +59 -0
- package/src/Content.class.json +117 -0
- package/src/ContentCollection.class.json +3 -3
- package/src/ContentEntry.class.json +1 -1
- package/src/content-loader.ts +480 -0
- package/src/content.ts +6 -4
- package/src/html-to-jx.ts +8 -117
- package/src/md-html.ts +5 -42
- package/src/serialize.ts +1 -1
- package/src/transpile.ts +2 -2
- package/src/types.ts +15 -18
package/src/md-html.ts
CHANGED
|
@@ -1,49 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Md-html —
|
|
2
|
+
* Md-html — compatibility shim.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 {
|