@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,191 @@
1
+ {
2
+ "type": "root",
3
+ "children": [
4
+ {
5
+ "type": "heading",
6
+ "depth": 1,
7
+ "children": [
8
+ {
9
+ "type": "text",
10
+ "value": "Heading 1",
11
+ "position": {
12
+ "start": {
13
+ "line": 1,
14
+ "column": 3,
15
+ "offset": 2
16
+ },
17
+ "end": {
18
+ "line": 1,
19
+ "column": 12,
20
+ "offset": 11
21
+ }
22
+ }
23
+ }
24
+ ],
25
+ "position": {
26
+ "start": {
27
+ "line": 1,
28
+ "column": 1,
29
+ "offset": 0
30
+ },
31
+ "end": {
32
+ "line": 1,
33
+ "column": 12,
34
+ "offset": 11
35
+ }
36
+ }
37
+ },
38
+ {
39
+ "type": "outputVars",
40
+ "name": "example",
41
+ "attributes": {},
42
+ "children": [
43
+ {
44
+ "type": "code",
45
+ "lang": "bash",
46
+ "meta": "npm",
47
+ "value": "npm i -g xyd-js",
48
+ "position": {
49
+ "start": {
50
+ "line": 5,
51
+ "column": 3,
52
+ "offset": 27
53
+ },
54
+ "end": {
55
+ "line": 7,
56
+ "column": 6,
57
+ "offset": 62
58
+ }
59
+ }
60
+ },
61
+ {
62
+ "type": "code",
63
+ "lang": "bash",
64
+ "meta": "yarn",
65
+ "value": "yarn global add xyd-js",
66
+ "position": {
67
+ "start": {
68
+ "line": 9,
69
+ "column": 3,
70
+ "offset": 66
71
+ },
72
+ "end": {
73
+ "line": 11,
74
+ "column": 6,
75
+ "offset": 109
76
+ }
77
+ }
78
+ },
79
+ {
80
+ "type": "code",
81
+ "lang": "bash",
82
+ "meta": "pnpm",
83
+ "value": "pnpm add -g xyd-js",
84
+ "position": {
85
+ "start": {
86
+ "line": 13,
87
+ "column": 3,
88
+ "offset": 113
89
+ },
90
+ "end": {
91
+ "line": 15,
92
+ "column": 6,
93
+ "offset": 152
94
+ }
95
+ }
96
+ }
97
+ ],
98
+ "position": {
99
+ "start": {
100
+ "line": 4,
101
+ "column": 1,
102
+ "offset": 14
103
+ },
104
+ "end": {
105
+ "line": 16,
106
+ "column": 4,
107
+ "offset": 156
108
+ }
109
+ }
110
+ },
111
+ {
112
+ "type": "heading",
113
+ "depth": 2,
114
+ "children": [
115
+ {
116
+ "type": "text",
117
+ "value": "Heading 2",
118
+ "position": {
119
+ "start": {
120
+ "line": 18,
121
+ "column": 4,
122
+ "offset": 161
123
+ },
124
+ "end": {
125
+ "line": 18,
126
+ "column": 13,
127
+ "offset": 170
128
+ }
129
+ }
130
+ }
131
+ ],
132
+ "position": {
133
+ "start": {
134
+ "line": 18,
135
+ "column": 1,
136
+ "offset": 158
137
+ },
138
+ "end": {
139
+ "line": 18,
140
+ "column": 13,
141
+ "offset": 170
142
+ }
143
+ }
144
+ },
145
+ {
146
+ "type": "paragraph",
147
+ "children": [
148
+ {
149
+ "type": "text",
150
+ "value": "Lorem ipsum",
151
+ "position": {
152
+ "start": {
153
+ "line": 20,
154
+ "column": 1,
155
+ "offset": 172
156
+ },
157
+ "end": {
158
+ "line": 20,
159
+ "column": 12,
160
+ "offset": 183
161
+ }
162
+ }
163
+ }
164
+ ],
165
+ "position": {
166
+ "start": {
167
+ "line": 20,
168
+ "column": 1,
169
+ "offset": 172
170
+ },
171
+ "end": {
172
+ "line": 20,
173
+ "column": 12,
174
+ "offset": 183
175
+ }
176
+ }
177
+ }
178
+ ],
179
+ "position": {
180
+ "start": {
181
+ "line": 1,
182
+ "column": 1,
183
+ "offset": 0
184
+ },
185
+ "end": {
186
+ "line": 23,
187
+ "column": 1,
188
+ "offset": 186
189
+ }
190
+ }
191
+ }
@@ -0,0 +1,21 @@
1
+ <<<example
2
+ ```bash npm
3
+ npm i -g xyd-js
4
+ ```
5
+
6
+ ```bash yarn
7
+ yarn global add xyd-js
8
+ ```
9
+
10
+ ```bash pnpm
11
+ pnpm add -g xyd-js
12
+ ```
13
+ <<<
14
+
15
+ <<<example2
16
+ ```tsx
17
+ function() {
18
+ return <div> Hello World </div>
19
+ }
20
+ ```
21
+ <<<
@@ -0,0 +1,127 @@
1
+ {
2
+ "type": "root",
3
+ "children": [
4
+ {
5
+ "type": "outputVars",
6
+ "name": "example",
7
+ "attributes": {},
8
+ "children": [
9
+ {
10
+ "type": "code",
11
+ "lang": "bash",
12
+ "meta": "npm",
13
+ "value": "npm i -g xyd-js",
14
+ "position": {
15
+ "start": {
16
+ "line": 2,
17
+ "column": 3,
18
+ "offset": 13
19
+ },
20
+ "end": {
21
+ "line": 4,
22
+ "column": 6,
23
+ "offset": 48
24
+ }
25
+ }
26
+ },
27
+ {
28
+ "type": "code",
29
+ "lang": "bash",
30
+ "meta": "yarn",
31
+ "value": "yarn global add xyd-js",
32
+ "position": {
33
+ "start": {
34
+ "line": 6,
35
+ "column": 3,
36
+ "offset": 52
37
+ },
38
+ "end": {
39
+ "line": 8,
40
+ "column": 6,
41
+ "offset": 95
42
+ }
43
+ }
44
+ },
45
+ {
46
+ "type": "code",
47
+ "lang": "bash",
48
+ "meta": "pnpm",
49
+ "value": "pnpm add -g xyd-js",
50
+ "position": {
51
+ "start": {
52
+ "line": 10,
53
+ "column": 3,
54
+ "offset": 99
55
+ },
56
+ "end": {
57
+ "line": 12,
58
+ "column": 6,
59
+ "offset": 138
60
+ }
61
+ }
62
+ }
63
+ ],
64
+ "position": {
65
+ "start": {
66
+ "line": 1,
67
+ "column": 1,
68
+ "offset": 0
69
+ },
70
+ "end": {
71
+ "line": 13,
72
+ "column": 4,
73
+ "offset": 142
74
+ }
75
+ }
76
+ },
77
+ {
78
+ "type": "outputVars",
79
+ "name": "example2",
80
+ "attributes": {},
81
+ "children": [
82
+ {
83
+ "type": "code",
84
+ "lang": "tsx",
85
+ "meta": null,
86
+ "value": "function() {\n return <div> Hello World </div>\n}",
87
+ "position": {
88
+ "start": {
89
+ "line": 16,
90
+ "column": 3,
91
+ "offset": 158
92
+ },
93
+ "end": {
94
+ "line": 20,
95
+ "column": 6,
96
+ "offset": 225
97
+ }
98
+ }
99
+ }
100
+ ],
101
+ "position": {
102
+ "start": {
103
+ "line": 15,
104
+ "column": 1,
105
+ "offset": 144
106
+ },
107
+ "end": {
108
+ "line": 21,
109
+ "column": 4,
110
+ "offset": 229
111
+ }
112
+ }
113
+ }
114
+ ],
115
+ "position": {
116
+ "start": {
117
+ "line": 1,
118
+ "column": 1,
119
+ "offset": 0
120
+ },
121
+ "end": {
122
+ "line": 22,
123
+ "column": 1,
124
+ "offset": 230
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,28 @@
1
+ import { describe, it } from 'vitest';
2
+
3
+ import { testFixture } from './testHelpers';
4
+
5
+ const tests = [
6
+ {
7
+ name: "1.simple",
8
+ description: "A simple example of output variables",
9
+ input: "1.simple/input.md",
10
+ output: "1.simple/output.json"
11
+ },
12
+ {
13
+ name: "2.multiple-vars",
14
+ description: "A example of multiple output variables",
15
+ input: "2.multiple-vars/input.md",
16
+ output: "2.multiple-vars/output.json"
17
+ }
18
+
19
+ ]
20
+
21
+ describe("outputVars", () => {
22
+ tests.forEach((test) => {
23
+ it(`[${test.name}]: ${test.description}`, async () => {
24
+ await testFixture(test.name);
25
+ });
26
+ });
27
+ });
28
+
@@ -0,0 +1,36 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+
4
+ import { remark } from 'remark'
5
+ import { expect } from 'vitest';
6
+
7
+ import { remarkOutputVars } from '../remarkOutputVars';
8
+
9
+ const fixturesDir = path.resolve(__dirname, '../__fixtures__');
10
+
11
+ // Helper function to run a test with a specific fixture
12
+ export async function testFixture(fixtureName: string) {
13
+ const input = readFixture(`${fixtureName}/input.md`);
14
+ const expectedOutput = readFixtureOutput(`${fixtureName}/output.json`);
15
+
16
+ const result = await processMarkdown(input)
17
+ expect(result).toEqual(expectedOutput);
18
+ }
19
+
20
+ // Helper function to read fixture files
21
+ function readFixture(name: string) {
22
+ const fixturePath = path.join(fixturesDir, name);
23
+ return fs.readFileSync(fixturePath, "utf8");
24
+ }
25
+
26
+ // Helper function to read fixture output
27
+ function readFixtureOutput(name: string) {
28
+ const fixturePath = path.join(fixturesDir, name);
29
+ return JSON.parse(fs.readFileSync(fixturePath, "utf8"));
30
+ }
31
+
32
+ function processMarkdown(input: string) {
33
+ return remark()
34
+ .use(remarkOutputVars)
35
+ .parse(input)
36
+ }
@@ -0,0 +1 @@
1
+ export { remarkOutputVars as outputVars } from './remarkOutputVars'
@@ -0,0 +1,4 @@
1
+ import { codes } from 'micromark-util-symbol'
2
+
3
+ export const PRIMARY_SYMBOL = codes.lessThan
4
+ export const PRIMARY_SYMBOL_STR = '>'