@xyd-js/content 0.0.0-build

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/ISSUES.md +1 -0
  3. package/LICENSE +21 -0
  4. package/README.md +3 -0
  5. package/TODO.md +2 -0
  6. package/dist/index.d.ts +28 -0
  7. package/dist/index.js +1625 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/md.d.ts +72 -0
  10. package/dist/md.js +23508 -0
  11. package/dist/md.js.map +1 -0
  12. package/dist/mdToc-NBBxMJ4l.d.ts +12 -0
  13. package/dist/vite.d.ts +1066 -0
  14. package/dist/vite.js +20156 -0
  15. package/dist/vite.js.map +1 -0
  16. package/package.json +67 -0
  17. package/packages/md/index.ts +25 -0
  18. package/packages/md/plugins/component-directives/index.ts +3 -0
  19. package/packages/md/plugins/component-directives/mdComponentDirective.ts +577 -0
  20. package/packages/md/plugins/component-directives/types.ts +1 -0
  21. package/packages/md/plugins/component-directives/utils.ts +27 -0
  22. package/packages/md/plugins/composer/__fixtures__/1.single-example/input.md +7 -0
  23. package/packages/md/plugins/composer/__fixtures__/1.single-example/output.json +63 -0
  24. package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/input.md +7 -0
  25. package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/output.json +63 -0
  26. package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/input.md +15 -0
  27. package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/output.json +122 -0
  28. package/packages/md/plugins/composer/__fixtures__/4.example-groups/input.md +23 -0
  29. package/packages/md/plugins/composer/__fixtures__/4.example-groups/output.json +184 -0
  30. package/packages/md/plugins/composer/__tests__/mdComposer.test.ts +41 -0
  31. package/packages/md/plugins/composer/__tests__/testHelpers.ts +48 -0
  32. package/packages/md/plugins/composer/index.ts +1 -0
  33. package/packages/md/plugins/composer/mdComposer.ts +146 -0
  34. package/packages/md/plugins/developer-writing/index.ts +3 -0
  35. package/packages/md/plugins/developer-writing/mdCodeRehype.ts +81 -0
  36. package/packages/md/plugins/functions/__fixtures__/external.ts +4 -0
  37. package/packages/md/plugins/functions/__fixtures__/test-include.md +31 -0
  38. package/packages/md/plugins/functions/__fixtures__/test.js +11 -0
  39. package/packages/md/plugins/functions/__fixtures__/test.py +9 -0
  40. package/packages/md/plugins/functions/__fixtures__/test.ts +18 -0
  41. package/packages/md/plugins/functions/__tests__/mdFunctionImportCode.test.ts +314 -0
  42. package/packages/md/plugins/functions/__tests__/mdFunctionInclude.test.ts +44 -0
  43. package/packages/md/plugins/functions/__tests__/parseFunctionCall.test.ts +70 -0
  44. package/packages/md/plugins/functions/__tests__/testHelpers.ts +95 -0
  45. package/packages/md/plugins/functions/index.ts +15 -0
  46. package/packages/md/plugins/functions/mdFunctionChangelog.ts +135 -0
  47. package/packages/md/plugins/functions/mdFunctionImportCode.ts +92 -0
  48. package/packages/md/plugins/functions/mdFunctionInclude.ts +119 -0
  49. package/packages/md/plugins/functions/mdFunctionUniform.ts +79 -0
  50. package/packages/md/plugins/functions/types.ts +9 -0
  51. package/packages/md/plugins/functions/uniformProcessor.ts +349 -0
  52. package/packages/md/plugins/functions/utils.ts +457 -0
  53. package/packages/md/plugins/index.ts +125 -0
  54. package/packages/md/plugins/mdCode.ts +16 -0
  55. package/packages/md/plugins/mdHeadingId.ts +47 -0
  56. package/packages/md/plugins/mdImage.test.ts +59 -0
  57. package/packages/md/plugins/mdImage.ts +55 -0
  58. package/packages/md/plugins/mdImageRehype.ts +13 -0
  59. package/packages/md/plugins/mdPage.ts +35 -0
  60. package/packages/md/plugins/mdThemeSettings.ts +34 -0
  61. package/packages/md/plugins/mdToc.ts +229 -0
  62. package/packages/md/plugins/meta/index.ts +1 -0
  63. package/packages/md/plugins/meta/mdMeta.ts +198 -0
  64. package/packages/md/plugins/output-variables/__fixtures__/1.simple/input.md +22 -0
  65. package/packages/md/plugins/output-variables/__fixtures__/1.simple/output.json +191 -0
  66. package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/input.md +21 -0
  67. package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/output.json +127 -0
  68. package/packages/md/plugins/output-variables/__tests__/index.test.ts +28 -0
  69. package/packages/md/plugins/output-variables/__tests__/testHelpers.ts +36 -0
  70. package/packages/md/plugins/output-variables/index.ts +1 -0
  71. package/packages/md/plugins/output-variables/lib/const.ts +4 -0
  72. package/packages/md/plugins/output-variables/lib/factoryAttributes.ts +350 -0
  73. package/packages/md/plugins/output-variables/lib/factoryLabel.ts +135 -0
  74. package/packages/md/plugins/output-variables/lib/factoryName.ts +59 -0
  75. package/packages/md/plugins/output-variables/lib/index.ts +21 -0
  76. package/packages/md/plugins/output-variables/lib/outputVarsContainer.ts +328 -0
  77. package/packages/md/plugins/output-variables/lib/util.ts +494 -0
  78. package/packages/md/plugins/output-variables/remarkOutputVars.ts +22 -0
  79. package/packages/md/plugins/recmaOverrideComponents.ts +74 -0
  80. package/packages/md/plugins/rehypeHeading.ts +58 -0
  81. package/packages/md/plugins/types.ts +15 -0
  82. package/packages/md/plugins/utils/componentLike.ts +76 -0
  83. package/packages/md/plugins/utils/index.ts +2 -0
  84. package/packages/md/plugins/utils/injectCodeMeta.ts +59 -0
  85. package/packages/md/plugins/utils/mdParameters.test.ts +114 -0
  86. package/packages/md/plugins/utils/mdParameters.ts +249 -0
  87. package/packages/md/plugins/utils/mdastTypes.ts +42 -0
  88. package/packages/md/search/index.ts +257 -0
  89. package/packages/md/search/types.ts +36 -0
  90. package/packages/vite/index.ts +20 -0
  91. package/src/fs.ts +81 -0
  92. package/src/index.ts +7 -0
  93. package/src/navigation.ts +147 -0
  94. package/src/types.ts +8 -0
  95. package/tsconfig.json +49 -0
  96. package/tsup.config.ts +32 -0
  97. package/vitest.config.ts +17 -0
@@ -0,0 +1,7 @@
1
+ <<<examples
2
+ ```jsx
3
+ function GuideCard() {
4
+ return <div> Guide Card </div>
5
+ }
6
+ ```
7
+ <<<
@@ -0,0 +1,63 @@
1
+ {
2
+ "examples": [
3
+ {
4
+ "value": "function GuideCard() {\n return <div> Guide Card </div>\n}",
5
+ "lang": "jsx",
6
+ "meta": null,
7
+ "code": "function GuideCard() {\n return <div> Guide Card </div>\n}",
8
+ "tokens": [
9
+ [
10
+ "function",
11
+ "#FF7B72"
12
+ ],
13
+ " ",
14
+ [
15
+ "GuideCard",
16
+ "#D2A8FF"
17
+ ],
18
+ [
19
+ "() {",
20
+ "#C9D1D9"
21
+ ],
22
+ "\n ",
23
+ [
24
+ "return",
25
+ "#FF7B72"
26
+ ],
27
+ " ",
28
+ [
29
+ "<",
30
+ "#C9D1D9"
31
+ ],
32
+ [
33
+ "div",
34
+ "#7EE787"
35
+ ],
36
+ [
37
+ "> Guide Card </",
38
+ "#C9D1D9"
39
+ ],
40
+ [
41
+ "div",
42
+ "#7EE787"
43
+ ],
44
+ [
45
+ ">",
46
+ "#C9D1D9"
47
+ ],
48
+ "\n",
49
+ [
50
+ "}",
51
+ "#C9D1D9"
52
+ ]
53
+ ],
54
+ "annotations": [],
55
+ "themeName": "github-dark",
56
+ "style": {
57
+ "color": "#c9d1d9",
58
+ "background": "#0d1117",
59
+ "colorScheme": "dark"
60
+ }
61
+ }
62
+ ]
63
+ }
@@ -0,0 +1,7 @@
1
+ <<<examples
2
+ ```jsx Guide Card Sample
3
+ function GuideCard() {
4
+ return <div> Guide Card </div>
5
+ }
6
+ ```
7
+ <<<
@@ -0,0 +1,63 @@
1
+ {
2
+ "examples": [
3
+ {
4
+ "value": "function GuideCard() {\n return <div> Guide Card </div>\n}",
5
+ "lang": "jsx",
6
+ "meta": "Guide Card Sample",
7
+ "code": "function GuideCard() {\n return <div> Guide Card </div>\n}",
8
+ "tokens": [
9
+ [
10
+ "function",
11
+ "#FF7B72"
12
+ ],
13
+ " ",
14
+ [
15
+ "GuideCard",
16
+ "#D2A8FF"
17
+ ],
18
+ [
19
+ "() {",
20
+ "#C9D1D9"
21
+ ],
22
+ "\n ",
23
+ [
24
+ "return",
25
+ "#FF7B72"
26
+ ],
27
+ " ",
28
+ [
29
+ "<",
30
+ "#C9D1D9"
31
+ ],
32
+ [
33
+ "div",
34
+ "#7EE787"
35
+ ],
36
+ [
37
+ "> Guide Card </",
38
+ "#C9D1D9"
39
+ ],
40
+ [
41
+ "div",
42
+ "#7EE787"
43
+ ],
44
+ [
45
+ ">",
46
+ "#C9D1D9"
47
+ ],
48
+ "\n",
49
+ [
50
+ "}",
51
+ "#C9D1D9"
52
+ ]
53
+ ],
54
+ "annotations": [],
55
+ "themeName": "github-dark",
56
+ "style": {
57
+ "color": "#c9d1d9",
58
+ "background": "#0d1117",
59
+ "colorScheme": "dark"
60
+ }
61
+ }
62
+ ]
63
+ }
@@ -0,0 +1,15 @@
1
+ <<<examples
2
+ -
3
+ ```jsx Card Group Sample
4
+ function GuideCard() {
5
+ return <div> Guide Card </div>
6
+ }
7
+ ```
8
+
9
+ -
10
+ ```tsx Card Group V2 Sample
11
+ function GuideCardV2() {
12
+ return <div> Guide Card V2 </div>
13
+ }
14
+ ```
15
+ <<<
@@ -0,0 +1,122 @@
1
+ {
2
+ "examples": [
3
+ {
4
+ "value": "function GuideCard() {\n return <div> Guide Card </div>\n}",
5
+ "lang": "jsx",
6
+ "meta": "Card Group Sample",
7
+ "code": "function GuideCard() {\n return <div> Guide Card </div>\n}",
8
+ "tokens": [
9
+ [
10
+ "function",
11
+ "#FF7B72"
12
+ ],
13
+ " ",
14
+ [
15
+ "GuideCard",
16
+ "#D2A8FF"
17
+ ],
18
+ [
19
+ "() {",
20
+ "#C9D1D9"
21
+ ],
22
+ "\n ",
23
+ [
24
+ "return",
25
+ "#FF7B72"
26
+ ],
27
+ " ",
28
+ [
29
+ "<",
30
+ "#C9D1D9"
31
+ ],
32
+ [
33
+ "div",
34
+ "#7EE787"
35
+ ],
36
+ [
37
+ "> Guide Card </",
38
+ "#C9D1D9"
39
+ ],
40
+ [
41
+ "div",
42
+ "#7EE787"
43
+ ],
44
+ [
45
+ ">",
46
+ "#C9D1D9"
47
+ ],
48
+ "\n",
49
+ [
50
+ "}",
51
+ "#C9D1D9"
52
+ ]
53
+ ],
54
+ "annotations": [],
55
+ "themeName": "github-dark",
56
+ "style": {
57
+ "color": "#c9d1d9",
58
+ "background": "#0d1117",
59
+ "colorScheme": "dark"
60
+ }
61
+ },
62
+ {
63
+ "value": "function GuideCardV2() {\n return <div> Guide Card V2 </div>\n}",
64
+ "lang": "tsx",
65
+ "meta": "Card Group V2 Sample",
66
+ "code": "function GuideCardV2() {\n return <div> Guide Card V2 </div>\n}",
67
+ "tokens": [
68
+ [
69
+ "function",
70
+ "#FF7B72"
71
+ ],
72
+ " ",
73
+ [
74
+ "GuideCardV2",
75
+ "#D2A8FF"
76
+ ],
77
+ [
78
+ "() {",
79
+ "#C9D1D9"
80
+ ],
81
+ "\n ",
82
+ [
83
+ "return",
84
+ "#FF7B72"
85
+ ],
86
+ " ",
87
+ [
88
+ "<",
89
+ "#C9D1D9"
90
+ ],
91
+ [
92
+ "div",
93
+ "#7EE787"
94
+ ],
95
+ [
96
+ "> Guide Card V2 </",
97
+ "#C9D1D9"
98
+ ],
99
+ [
100
+ "div",
101
+ "#7EE787"
102
+ ],
103
+ [
104
+ ">",
105
+ "#C9D1D9"
106
+ ],
107
+ "\n",
108
+ [
109
+ "}",
110
+ "#C9D1D9"
111
+ ]
112
+ ],
113
+ "annotations": [],
114
+ "themeName": "github-dark",
115
+ "style": {
116
+ "color": "#c9d1d9",
117
+ "background": "#0d1117",
118
+ "colorScheme": "dark"
119
+ }
120
+ }
121
+ ]
122
+ }
@@ -0,0 +1,23 @@
1
+ <<<examples
2
+ -
3
+ :::code-group{title="Guide Cards"}
4
+ ```jsx Guide Card Example
5
+ function GuideCard() {
6
+ return <div> Guide Card </div>
7
+ }
8
+ ```
9
+
10
+ ```tsx Card Group V2 Sample
11
+ function GuideCardV2() {
12
+ return <div> Guide Card V2 </div>
13
+ }
14
+ ```
15
+ :::
16
+
17
+ -
18
+ ```jsx
19
+ function GuideCard() {
20
+ return <div> Guide Card </div>
21
+ }
22
+ ```
23
+ <<<
@@ -0,0 +1,184 @@
1
+ {
2
+ "examples": [
3
+ [
4
+ "Guide Cards",
5
+ {
6
+ "value": "function GuideCard() {\n return <div> Guide Card </div>\n}",
7
+ "lang": "jsx",
8
+ "meta": "Guide Card Example",
9
+ "code": "function GuideCard() {\n return <div> Guide Card </div>\n}",
10
+ "tokens": [
11
+ [
12
+ "function",
13
+ "#FF7B72"
14
+ ],
15
+ " ",
16
+ [
17
+ "GuideCard",
18
+ "#D2A8FF"
19
+ ],
20
+ [
21
+ "() {",
22
+ "#C9D1D9"
23
+ ],
24
+ "\n ",
25
+ [
26
+ "return",
27
+ "#FF7B72"
28
+ ],
29
+ " ",
30
+ [
31
+ "<",
32
+ "#C9D1D9"
33
+ ],
34
+ [
35
+ "div",
36
+ "#7EE787"
37
+ ],
38
+ [
39
+ "> Guide Card </",
40
+ "#C9D1D9"
41
+ ],
42
+ [
43
+ "div",
44
+ "#7EE787"
45
+ ],
46
+ [
47
+ ">",
48
+ "#C9D1D9"
49
+ ],
50
+ "\n",
51
+ [
52
+ "}",
53
+ "#C9D1D9"
54
+ ]
55
+ ],
56
+ "annotations": [],
57
+ "themeName": "github-dark",
58
+ "style": {
59
+ "color": "#c9d1d9",
60
+ "background": "#0d1117",
61
+ "colorScheme": "dark"
62
+ }
63
+ },
64
+ {
65
+ "value": "function GuideCardV2() {\n return <div> Guide Card V2 </div>\n}",
66
+ "lang": "tsx",
67
+ "meta": "Card Group V2 Sample",
68
+ "code": "function GuideCardV2() {\n return <div> Guide Card V2 </div>\n}",
69
+ "tokens": [
70
+ [
71
+ "function",
72
+ "#FF7B72"
73
+ ],
74
+ " ",
75
+ [
76
+ "GuideCardV2",
77
+ "#D2A8FF"
78
+ ],
79
+ [
80
+ "() {",
81
+ "#C9D1D9"
82
+ ],
83
+ "\n ",
84
+ [
85
+ "return",
86
+ "#FF7B72"
87
+ ],
88
+ " ",
89
+ [
90
+ "<",
91
+ "#C9D1D9"
92
+ ],
93
+ [
94
+ "div",
95
+ "#7EE787"
96
+ ],
97
+ [
98
+ "> Guide Card V2 </",
99
+ "#C9D1D9"
100
+ ],
101
+ [
102
+ "div",
103
+ "#7EE787"
104
+ ],
105
+ [
106
+ ">",
107
+ "#C9D1D9"
108
+ ],
109
+ "\n",
110
+ [
111
+ "}",
112
+ "#C9D1D9"
113
+ ]
114
+ ],
115
+ "annotations": [],
116
+ "themeName": "github-dark",
117
+ "style": {
118
+ "color": "#c9d1d9",
119
+ "background": "#0d1117",
120
+ "colorScheme": "dark"
121
+ }
122
+ }
123
+ ],
124
+ {
125
+ "value": "function GuideCard() {\n return <div> Guide Card </div>\n}",
126
+ "lang": "jsx",
127
+ "meta": null,
128
+ "code": "function GuideCard() {\n return <div> Guide Card </div>\n}",
129
+ "tokens": [
130
+ [
131
+ "function",
132
+ "#FF7B72"
133
+ ],
134
+ " ",
135
+ [
136
+ "GuideCard",
137
+ "#D2A8FF"
138
+ ],
139
+ [
140
+ "() {",
141
+ "#C9D1D9"
142
+ ],
143
+ "\n ",
144
+ [
145
+ "return",
146
+ "#FF7B72"
147
+ ],
148
+ " ",
149
+ [
150
+ "<",
151
+ "#C9D1D9"
152
+ ],
153
+ [
154
+ "div",
155
+ "#7EE787"
156
+ ],
157
+ [
158
+ "> Guide Card </",
159
+ "#C9D1D9"
160
+ ],
161
+ [
162
+ "div",
163
+ "#7EE787"
164
+ ],
165
+ [
166
+ ">",
167
+ "#C9D1D9"
168
+ ],
169
+ "\n",
170
+ [
171
+ "}",
172
+ "#C9D1D9"
173
+ ]
174
+ ],
175
+ "annotations": [],
176
+ "themeName": "github-dark",
177
+ "style": {
178
+ "color": "#c9d1d9",
179
+ "background": "#0d1117",
180
+ "colorScheme": "dark"
181
+ }
182
+ }
183
+ ]
184
+ }
@@ -0,0 +1,41 @@
1
+ import { describe, it } from 'vitest';
2
+
3
+ import { testFixture } from './testHelpers';
4
+
5
+
6
+ const tests = [
7
+ {
8
+ name: "1.single-example",
9
+ description: "A single example",
10
+ input: "1.single-example/input.md",
11
+ output: "1.single-example/output.md"
12
+ },
13
+ {
14
+ name: "2.single-example-with-name",
15
+ description: "A single example with a name",
16
+ input: "2.single-example-with-name/input.md",
17
+ output: "2.single-example-with-name/output.md"
18
+ },
19
+ {
20
+ name: "3.multiple-examples",
21
+ description: "Multiple examples",
22
+ input: "3.multiple-examples/input.md",
23
+ output: "3.multiple-examples/output.md"
24
+ },
25
+ {
26
+ name: "4.example-groups",
27
+ description: "Example groups",
28
+ input: "4.example-groups/input.md",
29
+ output: "4.example-groups/output.md"
30
+ }
31
+ ]
32
+
33
+ describe("mdComposer", () => {
34
+ tests.forEach((test) => {
35
+ it(`[${test.name}]: ${test.description}`, async () => {
36
+ await testFixture(test.name);
37
+ });
38
+ });
39
+ });
40
+
41
+
@@ -0,0 +1,48 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { describe, it, expect } from 'vitest';
4
+ import { remark } from 'remark'
5
+ import remarkDirective from "remark-directive";
6
+
7
+ import { mdComposer } from "../mdComposer";
8
+ import { outputVars } from '../../output-variables';
9
+ import { SymbolxVfile } from "../../types";
10
+
11
+ interface TestOutputVariables {
12
+ examples: string
13
+ }
14
+
15
+ // Helper function to run a test with a specific fixture
16
+ export async function testFixture(fixtureName: string) {
17
+ const input = readFixture(`${fixtureName}/input.md`);
18
+ const expectedOutput = readFixtureOutput(`${fixtureName}/output.json`);
19
+
20
+ const result = await processMarkdown(input);
21
+ const output = result as SymbolxVfile<TestOutputVariables>
22
+ const examples = output.data.outputVars?.examples
23
+
24
+ expect(examples).toEqual(expectedOutput.examples);
25
+ }
26
+
27
+ // Helper function to process markdown with the mdComposer plugin
28
+ async function processMarkdown(input: string) {
29
+ return await remark()
30
+ .use(outputVars)
31
+ .use(mdComposer())
32
+ .use(remarkDirective)
33
+ .process(input);
34
+ }
35
+
36
+
37
+ // Helper function to read fixture files
38
+ function readFixture(name: string) {
39
+ const fixturePath = path.join(__dirname, "../__fixtures__", name);
40
+ return fs.readFileSync(fixturePath, "utf8");
41
+ }
42
+
43
+ // Helper function to read fixture output
44
+ function readFixtureOutput(name: string) {
45
+ const fixturePath = path.join(__dirname, "../__fixtures__", name);
46
+ return JSON.parse(fs.readFileSync(fixturePath, "utf8"));
47
+ }
48
+
@@ -0,0 +1 @@
1
+ export { mdComposer } from './mdComposer';