@xyd-js/content 0.0.0-build-2acf05c-20251207022018 → 0.0.0-build-8a0317f-20251214165542

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyd-js/content",
3
- "version": "0.0.0-build-2acf05c-20251207022018",
3
+ "version": "0.0.0-build-8a0317f-20251214165542",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -38,14 +38,14 @@
38
38
  "unist-util-visit": "^5.0.0",
39
39
  "vfile": "^6.0.3",
40
40
  "vfile-matter": "^5.0.1",
41
- "@xyd-js/context": "0.0.0-build-2acf05c-20251207022018",
42
- "@xyd-js/core": "0.0.0-build-2acf05c-20251207022018",
43
- "@xyd-js/gql": "0.0.0-build-2acf05c-20251207022018",
44
- "@xyd-js/openapi": "0.0.0-build-2acf05c-20251207022018",
45
- "@xyd-js/sources": "0.0.0-build-2acf05c-20251207022018"
41
+ "@xyd-js/context": "0.0.0-build-8a0317f-20251214165542",
42
+ "@xyd-js/core": "0.0.0-build-8a0317f-20251214165542",
43
+ "@xyd-js/gql": "0.0.0-build-8a0317f-20251214165542",
44
+ "@xyd-js/openapi": "0.0.0-build-8a0317f-20251214165542",
45
+ "@xyd-js/sources": "0.0.0-build-8a0317f-20251214165542"
46
46
  },
47
47
  "peerDependencies": {
48
- "@xyd-js/components": "0.0.0-build-2acf05c-20251207022018"
48
+ "@xyd-js/components": "0.0.0-build-8a0317f-20251214165542"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.14.1",
@@ -33,6 +33,7 @@ export function mdCodeRehype(settings?: Settings) {
33
33
  const descriptionHead = node.children?.[0]?.properties?.descriptionHead
34
34
  const descriptionContent = node.children?.[0]?.properties?.descriptionContent
35
35
  const descriptionIcon = node.children?.[0]?.properties?.descriptionIcon
36
+ let attributes = node.children?.[0]?.properties?.attributes
36
37
  const meta = node.children?.[0]?.properties?.meta
37
38
  const title = node.children?.[0]?.properties?.title
38
39
 
@@ -66,7 +67,8 @@ export function mdCodeRehype(settings?: Settings) {
66
67
  size,
67
68
  descriptionHead,
68
69
  descriptionContent: descriptionContentCode,
69
- descriptionIcon
70
+ descriptionIcon,
71
+ attributes
70
72
  };
71
73
  })()
72
74
 
@@ -50,6 +50,9 @@ export function injectCodeMeta(node: any, metaString?: string) {
50
50
  if (attributes?.title === "false") {
51
51
  props.title = "";
52
52
  }
53
+ if (attributes) {
54
+ props.attributes = JSON.stringify(attributes)
55
+ }
53
56
 
54
57
  node.data.hProperties = {
55
58
  ...(node.data.hProperties || {}),
package/src/fs.test.ts ADDED
@@ -0,0 +1,42 @@
1
+ import {remarkDefinitionList, defListHastHandlers} from 'remark-definition-list';
2
+ import {describe, expect, it} from "vitest";
3
+
4
+ import {markdownPlugins} from "../packages/md";
5
+ import {ContentFS} from "./fs";
6
+
7
+ const md = `
8
+ Test for defList.
9
+
10
+ Apple
11
+ : Pomaceous fruit of plants of the genus Malus in
12
+ the family Rosaceae.
13
+
14
+ Orange
15
+ : The fruit of an evergreen tree of the genus Citrus.
16
+ `;
17
+
18
+ describe("ContentFS", () => {
19
+ it("compiles markdown using markdownPlugins (definition list)", async () => {
20
+ const {remarkPlugins, rehypePlugins, recmaPlugins} = await markdownPlugins(
21
+ {},
22
+ {} as any
23
+ );
24
+
25
+ const contentFs = new ContentFS(
26
+ {} as any,
27
+ [remarkDefinitionList, ...remarkPlugins],
28
+ rehypePlugins,
29
+ recmaPlugins,
30
+ defListHastHandlers,
31
+ );
32
+
33
+ const compiled = await contentFs.compileContent(md);
34
+
35
+ expect(typeof compiled).toBe("string");
36
+ console.log(compiled)
37
+ expect(compiled).toContain("Pomaceous fruit of plants of the genus Malus");
38
+ expect(compiled).toContain(
39
+ "The fruit of an evergreen tree of the genus Citrus."
40
+ );
41
+ });
42
+ });
package/src/fs.ts CHANGED
@@ -17,6 +17,7 @@ export class ContentFS {
17
17
  private readonly remarkPlugins: PluggableList,
18
18
  private readonly rehypePlugins: PluggableList,
19
19
  private readonly recmaPlugins: PluggableList,
20
+ private readonly remarkRehypeHandlers?: any
20
21
  ) { }
21
22
 
22
23
  public async compile(filePath: string): Promise<string> {
@@ -41,6 +42,11 @@ export class ContentFS {
41
42
  development: false,
42
43
  outputFormat: 'function-body',
43
44
  jsx: false,
45
+ remarkRehypeOptions: {
46
+ handlers: {
47
+ ...(this.remarkRehypeHandlers || {}),
48
+ }
49
+ }
44
50
  // jsx: false,
45
51
  // outputFormat: "program", // needed for import/export
46
52
  });
@@ -63,6 +69,11 @@ export class ContentFS {
63
69
  development: false,
64
70
  jsx: true,
65
71
  outputFormat: "program", // needed for import/export
72
+ remarkRehypeOptions: {
73
+ handlers: {
74
+ ...(this.remarkRehypeHandlers || {}),
75
+ }
76
+ }
66
77
  });
67
78
 
68
79
  const tempPath = join(tmpdir(), `mdx-${Date.now()}.mjs`);