pd-markdown 1.0.0 → 1.0.1

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 (170) hide show
  1. package/README.md +293 -0
  2. package/package.json +68 -1
  3. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.d.ts +0 -4
  4. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.d.ts.map +0 -1
  5. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.js +0 -5
  6. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/index.js.map +0 -1
  7. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.d.ts +0 -4
  8. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.d.ts.map +0 -1
  9. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.js +0 -4
  10. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/index.js.map +0 -1
  11. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.d.ts +0 -6
  12. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.d.ts.map +0 -1
  13. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.js +0 -36
  14. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/heading.js.map +0 -1
  15. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.d.ts +0 -14
  16. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.d.ts.map +0 -1
  17. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.js +0 -18
  18. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/list.js.map +0 -1
  19. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.d.ts +0 -27
  20. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.d.ts.map +0 -1
  21. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.js +0 -37
  22. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/plugins/transform/table.js.map +0 -1
  23. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.d.ts +0 -22
  24. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.d.ts.map +0 -1
  25. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.js +0 -95
  26. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/processor.js.map +0 -1
  27. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.d.ts +0 -55
  28. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.d.ts.map +0 -1
  29. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.js +0 -2
  30. package/packages/parser/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/parser/dist/types/index.js.map +0 -1
  31. package/packages/parser/__tests__/frontmatter.test.ts +0 -69
  32. package/packages/parser/__tests__/gfm.test.ts +0 -83
  33. package/packages/parser/__tests__/processor.test.ts +0 -136
  34. package/packages/parser/__tests__/transform/heading.test.ts +0 -56
  35. package/packages/parser/__tests__/transform/list.test.ts +0 -67
  36. package/packages/parser/__tests__/transform/table.test.ts +0 -85
  37. package/packages/parser/node_modules/.bin/yaml +0 -17
  38. package/packages/parser/package.json +0 -38
  39. package/packages/parser/rollup.config.ts +0 -38
  40. package/packages/parser/src/index.ts +0 -15
  41. package/packages/parser/src/plugins/index.ts +0 -3
  42. package/packages/parser/src/plugins/transform/heading.ts +0 -40
  43. package/packages/parser/src/plugins/transform/list.ts +0 -29
  44. package/packages/parser/src/plugins/transform/table.ts +0 -62
  45. package/packages/parser/src/processor.ts +0 -119
  46. package/packages/parser/src/types/index.ts +0 -60
  47. package/packages/parser/tsconfig.json +0 -9
  48. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.d.ts +0 -36
  49. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.d.ts.map +0 -1
  50. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.js +0 -99
  51. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/query.js.map +0 -1
  52. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.d.ts +0 -22
  53. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.d.ts.map +0 -1
  54. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.js +0 -46
  55. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/ast/traverse.js.map +0 -1
  56. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.d.ts +0 -7
  57. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.d.ts.map +0 -1
  58. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.js +0 -8
  59. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/index.js.map +0 -1
  60. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.d.ts +0 -22
  61. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.d.ts.map +0 -1
  62. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.js +0 -140
  63. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/sanitize.js.map +0 -1
  64. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.d.ts +0 -16
  65. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.d.ts.map +0 -1
  66. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.js +0 -39
  67. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/string/slugify.js.map +0 -1
  68. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.d.ts +0 -49
  69. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.d.ts.map +0 -1
  70. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.js +0 -19
  71. package/packages/utils/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/utils/dist/types/index.js.map +0 -1
  72. package/packages/utils/__tests__/query.test.ts +0 -155
  73. package/packages/utils/__tests__/sanitize.test.ts +0 -96
  74. package/packages/utils/__tests__/slugify.test.ts +0 -71
  75. package/packages/utils/__tests__/traverse.test.ts +0 -131
  76. package/packages/utils/package.json +0 -27
  77. package/packages/utils/rollup.config.ts +0 -26
  78. package/packages/utils/src/ast/query.ts +0 -127
  79. package/packages/utils/src/ast/traverse.ts +0 -73
  80. package/packages/utils/src/index.ts +0 -20
  81. package/packages/utils/src/string/sanitize.ts +0 -155
  82. package/packages/utils/src/string/slugify.ts +0 -43
  83. package/packages/utils/src/types/index.ts +0 -72
  84. package/packages/utils/tsconfig.json +0 -8
  85. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.d.ts +0 -27
  86. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.d.ts.map +0 -1
  87. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.js +0 -39
  88. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/MarkdownRenderer.js.map +0 -1
  89. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.d.ts +0 -10
  90. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.d.ts.map +0 -1
  91. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.js +0 -130
  92. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/NodeRenderer.js.map +0 -1
  93. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.d.ts +0 -17
  94. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.d.ts.map +0 -1
  95. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.js +0 -14
  96. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/context.js.map +0 -1
  97. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.d.ts +0 -8
  98. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.d.ts.map +0 -1
  99. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.js +0 -5
  100. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Blockquote.js.map +0 -1
  101. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.d.ts +0 -13
  102. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.d.ts.map +0 -1
  103. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.js +0 -9
  104. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Code.js.map +0 -1
  105. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.d.ts +0 -8
  106. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.d.ts.map +0 -1
  107. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.js +0 -7
  108. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Heading.js.map +0 -1
  109. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.d.ts +0 -7
  110. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.d.ts.map +0 -1
  111. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.js +0 -5
  112. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Image.js.map +0 -1
  113. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.d.ts +0 -8
  114. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.d.ts.map +0 -1
  115. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.js +0 -7
  116. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Link.js.map +0 -1
  117. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.d.ts +0 -13
  118. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.d.ts.map +0 -1
  119. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.js +0 -14
  120. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/List.js.map +0 -1
  121. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.d.ts +0 -8
  122. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.d.ts.map +0 -1
  123. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.js +0 -5
  124. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Paragraph.js.map +0 -1
  125. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.d.ts +0 -19
  126. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.d.ts.map +0 -1
  127. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.js +0 -18
  128. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/Table.js.map +0 -1
  129. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.d.ts +0 -34
  130. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.d.ts.map +0 -1
  131. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.js +0 -28
  132. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/components/defaults/index.js.map +0 -1
  133. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.d.ts +0 -11
  134. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.d.ts.map +0 -1
  135. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.js +0 -28
  136. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/hooks/useMarkdown.js.map +0 -1
  137. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.d.ts +0 -6
  138. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.d.ts.map +0 -1
  139. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.js +0 -9
  140. package/packages/web/.rollup.cache/Users/pidan/Work/Learn/pd-markdown/packages/web/dist/index.js.map +0 -1
  141. package/packages/web/__tests__/MarkdownRenderer.test.tsx +0 -89
  142. package/packages/web/__tests__/NodeRenderer.test.tsx +0 -97
  143. package/packages/web/__tests__/components/Code.test.tsx +0 -71
  144. package/packages/web/__tests__/components/Heading.test.tsx +0 -65
  145. package/packages/web/__tests__/components/List.test.tsx +0 -100
  146. package/packages/web/__tests__/components/Table.test.tsx +0 -105
  147. package/packages/web/__tests__/useMarkdown.test.ts +0 -63
  148. package/packages/web/package.json +0 -40
  149. package/packages/web/rollup.config.ts +0 -36
  150. package/packages/web/src/components/MarkdownRenderer.tsx +0 -70
  151. package/packages/web/src/components/NodeRenderer.tsx +0 -205
  152. package/packages/web/src/components/context.ts +0 -24
  153. package/packages/web/src/components/defaults/Blockquote.tsx +0 -11
  154. package/packages/web/src/components/defaults/Code.tsx +0 -26
  155. package/packages/web/src/components/defaults/Heading.tsx +0 -14
  156. package/packages/web/src/components/defaults/Image.tsx +0 -10
  157. package/packages/web/src/components/defaults/Link.tsx +0 -18
  158. package/packages/web/src/components/defaults/List.tsx +0 -33
  159. package/packages/web/src/components/defaults/Paragraph.tsx +0 -11
  160. package/packages/web/src/components/defaults/Table.tsx +0 -50
  161. package/packages/web/src/components/defaults/index.tsx +0 -80
  162. package/packages/web/src/hooks/useMarkdown.ts +0 -32
  163. package/packages/web/src/index.ts +0 -37
  164. package/packages/web/tsconfig.json +0 -11
  165. package/packages/web/vitest.config.ts +0 -9
  166. package/pnpm-workspace.yaml +0 -2
  167. package/tsconfig.base.json +0 -26
  168. package/tsconfig.json +0 -8
  169. package/vitest.config.ts +0 -28
  170. package/vitest.setup.ts +0 -1
@@ -1,11 +0,0 @@
1
- import type { Root } from 'mdast';
2
- import { type ParserOptions } from '@pd-markdown/parser';
3
- /**
4
- * Hook for parsing markdown on the client side
5
- *
6
- * @param source - Markdown source string
7
- * @param options - Parser options
8
- * @returns Parsed AST
9
- */
10
- export declare function useMarkdown(source: string, options?: ParserOptions): Root;
11
- //# sourceMappingURL=useMarkdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMarkdown.d.ts","sourceRoot":"","sources":["../../src/hooks/useMarkdown.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAetE;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAOzE"}
@@ -1,28 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { createParser } from '@pd-markdown/parser';
3
- // Cached parser instance
4
- let cachedParser = null;
5
- function getParser(options) {
6
- if (options) {
7
- return createParser(options);
8
- }
9
- if (!cachedParser) {
10
- cachedParser = createParser();
11
- }
12
- return cachedParser;
13
- }
14
- /**
15
- * Hook for parsing markdown on the client side
16
- *
17
- * @param source - Markdown source string
18
- * @param options - Parser options
19
- * @returns Parsed AST
20
- */
21
- export function useMarkdown(source, options) {
22
- const ast = useMemo(() => {
23
- const parser = getParser(options);
24
- return parser.parse(source);
25
- }, [source, options]);
26
- return ast;
27
- }
28
- //# sourceMappingURL=useMarkdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMarkdown.js","sourceRoot":"","sources":["../../src/hooks/useMarkdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAA;AAEtE,yBAAyB;AACzB,IAAI,YAAY,GAA2C,IAAI,CAAA;AAE/D,SAAS,SAAS,CAAC,OAAuB;IACxC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,YAAY,CAAC,OAAO,CAAC,CAAA;IAC9B,CAAC;IACD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,YAAY,EAAE,CAAA;IAC/B,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,OAAuB;IACjE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;QACvB,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;QACjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAErB,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1,6 +0,0 @@
1
- export { MarkdownRenderer, type MarkdownRendererProps } from './components/MarkdownRenderer';
2
- export { NodeRenderer, type NodeRendererProps } from './components/NodeRenderer';
3
- export { MarkdownContext, useMarkdownContext, type MarkdownContextValue } from './components/context';
4
- export { Heading, Paragraph, List, ListItem, Table, TableRow, TableCell, Code, InlineCodeComponent, Link, Image, Blockquote, defaultComponents, type ComponentMap, type HeadingProps, type ParagraphProps, type ListProps, type ListItemProps, type TableProps, type TableRowProps, type TableCellProps, type CodeProps, type InlineCodeProps, type LinkProps, type ImageProps, type BlockquoteProps, } from './components/defaults';
5
- export { useMarkdown } from './hooks/useMarkdown';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAGrG,OAAO,EACL,OAAO,EACP,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,mBAAmB,EACnB,IAAI,EACJ,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1,9 +0,0 @@
1
- // Components
2
- export { MarkdownRenderer } from './components/MarkdownRenderer';
3
- export { NodeRenderer } from './components/NodeRenderer';
4
- export { MarkdownContext, useMarkdownContext } from './components/context';
5
- // Default components
6
- export { Heading, Paragraph, List, ListItem, Table, TableRow, TableCell, Code, InlineCodeComponent, Link, Image, Blockquote, defaultComponents, } from './components/defaults';
7
- // Hooks
8
- export { useMarkdown } from './hooks/useMarkdown';
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,gBAAgB,EAA8B,MAAM,+BAA+B,CAAA;AAC5F,OAAO,EAAE,YAAY,EAA0B,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAA6B,MAAM,sBAAsB,CAAA;AAErG,qBAAqB;AACrB,OAAO,EACL,OAAO,EACP,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,mBAAmB,EACnB,IAAI,EACJ,KAAK,EACL,UAAU,EACV,iBAAiB,GAclB,MAAM,uBAAuB,CAAA;AAE9B,QAAQ;AACR,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1,89 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { render, screen } from '@testing-library/react'
3
- import { MarkdownRenderer } from '../src/components/MarkdownRenderer'
4
- import { createParser } from '@pd-markdown/parser'
5
-
6
- describe('MarkdownRenderer', () => {
7
- it('should render markdown string', () => {
8
- render(<MarkdownRenderer source="# Hello World" />)
9
-
10
- expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Hello World')
11
- })
12
-
13
- it('should render pre-parsed AST', () => {
14
- const parser = createParser()
15
- const ast = parser.parse('# From AST')
16
-
17
- render(<MarkdownRenderer ast={ast} />)
18
-
19
- expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('From AST')
20
- })
21
-
22
- it('should render nothing when no content provided', () => {
23
- const { container } = render(<MarkdownRenderer />)
24
-
25
- expect(container.firstChild).toBeNull()
26
- })
27
-
28
- it('should apply className', () => {
29
- const { container } = render(
30
- <MarkdownRenderer source="# Test" className="markdown-body" />
31
- )
32
-
33
- expect(container.firstChild).toHaveClass('markdown-body')
34
- })
35
-
36
- it('should apply inline styles', () => {
37
- const { container } = render(
38
- <MarkdownRenderer source="# Test" style={{ color: 'red' }} />
39
- )
40
-
41
- expect(container.firstChild).toHaveStyle({ color: 'rgb(255, 0, 0)' })
42
- })
43
-
44
- it('should support custom components override', () => {
45
- const CustomHeading = ({ children }: { children: React.ReactNode }) => (
46
- <div data-testid="custom-heading">{children}</div>
47
- )
48
-
49
- render(
50
- <MarkdownRenderer
51
- source="# Custom"
52
- components={{ heading: CustomHeading as any }}
53
- />
54
- )
55
-
56
- expect(screen.getByTestId('custom-heading')).toHaveTextContent('Custom')
57
- })
58
-
59
- it('should render multiple elements', () => {
60
- render(
61
- <MarkdownRenderer
62
- source={`
63
- # Heading
64
-
65
- Paragraph text.
66
-
67
- - Item 1
68
- - Item 2
69
- `.trim()}
70
- />
71
- )
72
-
73
- expect(screen.getByRole('heading')).toBeInTheDocument()
74
- expect(screen.getByText('Paragraph text.')).toBeInTheDocument()
75
- expect(screen.getByRole('list')).toBeInTheDocument()
76
- })
77
- })
78
-
79
- describe('MarkdownRenderer SSR compatibility', () => {
80
- it('should render from AST without re-parsing', () => {
81
- const parser = createParser()
82
- const ast = parser.parse('# Pre-rendered')
83
-
84
- // This simulates SSR where AST is passed directly
85
- const { container } = render(<MarkdownRenderer ast={ast} />)
86
-
87
- expect(container.querySelector('h1')).toHaveTextContent('Pre-rendered')
88
- })
89
- })
@@ -1,97 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { render, screen } from '@testing-library/react'
3
- import { NodeRenderer } from '../src/components/NodeRenderer'
4
- import { MarkdownContext } from '../src/components/context'
5
- import type { Root, Heading, Paragraph } from 'mdast'
6
-
7
- const renderWithContext = (node: any, components = {}) => {
8
- return render(
9
- <MarkdownContext.Provider value={{ components }}>
10
- <NodeRenderer node={node} />
11
- </MarkdownContext.Provider>
12
- )
13
- }
14
-
15
- describe('NodeRenderer', () => {
16
- it('should render root node', () => {
17
- const root: Root = {
18
- type: 'root',
19
- children: [
20
- {
21
- type: 'paragraph',
22
- children: [{ type: 'text', value: 'Hello' }],
23
- } as Paragraph,
24
- ],
25
- }
26
-
27
- renderWithContext(root)
28
- expect(screen.getByText('Hello')).toBeInTheDocument()
29
- })
30
-
31
- it('should render heading with correct level', () => {
32
- const heading: Heading = {
33
- type: 'heading',
34
- depth: 2,
35
- children: [{ type: 'text', value: 'Title' }],
36
- }
37
-
38
- renderWithContext(heading)
39
- expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent('Title')
40
- })
41
-
42
- it('should render heading with id from data', () => {
43
- const heading: Heading = {
44
- type: 'heading',
45
- depth: 1,
46
- children: [{ type: 'text', value: 'Hello' }],
47
- data: { id: 'hello' },
48
- }
49
-
50
- renderWithContext(heading)
51
- expect(screen.getByRole('heading')).toHaveAttribute('id', 'hello')
52
- })
53
-
54
- it('should render inline formatting', () => {
55
- const paragraph: Paragraph = {
56
- type: 'paragraph',
57
- children: [
58
- { type: 'text', value: 'Hello ' },
59
- { type: 'strong', children: [{ type: 'text', value: 'bold' }] },
60
- { type: 'text', value: ' and ' },
61
- { type: 'emphasis', children: [{ type: 'text', value: 'italic' }] },
62
- ],
63
- }
64
-
65
- const { container } = renderWithContext(paragraph)
66
- expect(container.querySelector('strong')).toHaveTextContent('bold')
67
- expect(container.querySelector('em')).toHaveTextContent('italic')
68
- })
69
-
70
- it('should handle unknown node types gracefully', () => {
71
- const unknown = {
72
- type: 'unknown-type',
73
- children: [
74
- { type: 'paragraph', children: [{ type: 'text', value: 'Content' }] },
75
- ],
76
- }
77
-
78
- // Should not throw and should try to render children
79
- renderWithContext(unknown)
80
- expect(screen.getByText('Content')).toBeInTheDocument()
81
- })
82
-
83
- it('should use custom component override', () => {
84
- const heading: Heading = {
85
- type: 'heading',
86
- depth: 1,
87
- children: [{ type: 'text', value: 'Custom' }],
88
- }
89
-
90
- const CustomHeading = ({ children }: { children: React.ReactNode }) => (
91
- <span data-testid="custom">{children}</span>
92
- )
93
-
94
- renderWithContext(heading, { heading: CustomHeading })
95
- expect(screen.getByTestId('custom')).toHaveTextContent('Custom')
96
- })
97
- })
@@ -1,71 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { render, screen } from '@testing-library/react'
3
- import { Code, InlineCodeComponent } from '../../src/components/defaults/Code'
4
- import type { Code as CodeNode, InlineCode } from 'mdast'
5
-
6
- describe('Code component', () => {
7
- it('should render code block', () => {
8
- const node: CodeNode = {
9
- type: 'code',
10
- value: 'const x = 1',
11
- }
12
-
13
- const { container } = render(<Code node={node} />)
14
- expect(container.querySelector('pre code')).toHaveTextContent('const x = 1')
15
- })
16
-
17
- it('should add language class', () => {
18
- const node: CodeNode = {
19
- type: 'code',
20
- lang: 'javascript',
21
- value: 'const x = 1',
22
- }
23
-
24
- const { container } = render(<Code node={node} />)
25
- expect(container.querySelector('code')).toHaveClass('language-javascript')
26
- })
27
-
28
- it('should handle missing language', () => {
29
- const node: CodeNode = {
30
- type: 'code',
31
- value: 'plain text',
32
- }
33
-
34
- const { container } = render(<Code node={node} />)
35
- expect(container.querySelector('code')).not.toHaveClass()
36
- })
37
-
38
- it('should preserve whitespace', () => {
39
- const node: CodeNode = {
40
- type: 'code',
41
- value: 'line 1\n line 2\n line 3',
42
- }
43
-
44
- const { container } = render(<Code node={node} />)
45
- expect(container.querySelector('code')?.textContent).toBe(
46
- 'line 1\n line 2\n line 3'
47
- )
48
- })
49
- })
50
-
51
- describe('InlineCodeComponent', () => {
52
- it('should render inline code', () => {
53
- const node: InlineCode = {
54
- type: 'inlineCode',
55
- value: 'code',
56
- }
57
-
58
- render(<InlineCodeComponent node={node} />)
59
- expect(screen.getByText('code').tagName).toBe('CODE')
60
- })
61
-
62
- it('should not be wrapped in pre', () => {
63
- const node: InlineCode = {
64
- type: 'inlineCode',
65
- value: 'inline',
66
- }
67
-
68
- const { container } = render(<InlineCodeComponent node={node} />)
69
- expect(container.querySelector('pre')).not.toBeInTheDocument()
70
- })
71
- })
@@ -1,65 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { render, screen } from '@testing-library/react'
3
- import { Heading } from '../../src/components/defaults/Heading'
4
- import type { Heading as HeadingNode } from 'mdast'
5
-
6
- describe('Heading component', () => {
7
- it('should render h1', () => {
8
- const node: HeadingNode = {
9
- type: 'heading',
10
- depth: 1,
11
- children: [{ type: 'text', value: 'Title' }],
12
- }
13
-
14
- render(<Heading node={node}>Title</Heading>)
15
- expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument()
16
- })
17
-
18
- it('should render h2', () => {
19
- const node: HeadingNode = {
20
- type: 'heading',
21
- depth: 2,
22
- children: [],
23
- }
24
-
25
- render(<Heading node={node}>Subtitle</Heading>)
26
- expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument()
27
- })
28
-
29
- it('should render h3-h6', () => {
30
- for (let depth = 3; depth <= 6; depth++) {
31
- const node: HeadingNode = {
32
- type: 'heading',
33
- depth: depth as 1 | 2 | 3 | 4 | 5 | 6,
34
- children: [],
35
- }
36
-
37
- const { unmount } = render(<Heading node={node}>Heading</Heading>)
38
- expect(screen.getByRole('heading', { level: depth })).toBeInTheDocument()
39
- unmount()
40
- }
41
- })
42
-
43
- it('should add id from data', () => {
44
- const node: HeadingNode = {
45
- type: 'heading',
46
- depth: 1,
47
- children: [],
48
- data: { id: 'my-heading' },
49
- }
50
-
51
- render(<Heading node={node}>My Heading</Heading>)
52
- expect(screen.getByRole('heading')).toHaveAttribute('id', 'my-heading')
53
- })
54
-
55
- it('should handle missing data', () => {
56
- const node: HeadingNode = {
57
- type: 'heading',
58
- depth: 1,
59
- children: [],
60
- }
61
-
62
- render(<Heading node={node}>No ID</Heading>)
63
- expect(screen.getByRole('heading')).not.toHaveAttribute('id')
64
- })
65
- })
@@ -1,100 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { render, screen } from '@testing-library/react'
3
- import { List, ListItem } from '../../src/components/defaults/List'
4
- import type { List as ListNode, ListItem as ListItemNode } from 'mdast'
5
-
6
- describe('List component', () => {
7
- it('should render unordered list', () => {
8
- const node: ListNode = {
9
- type: 'list',
10
- ordered: false,
11
- children: [],
12
- }
13
-
14
- const { container } = render(<List node={node}>Items</List>)
15
- expect(container.querySelector('ul')).toBeInTheDocument()
16
- })
17
-
18
- it('should render ordered list', () => {
19
- const node: ListNode = {
20
- type: 'list',
21
- ordered: true,
22
- children: [],
23
- }
24
-
25
- const { container } = render(<List node={node}>Items</List>)
26
- expect(container.querySelector('ol')).toBeInTheDocument()
27
- })
28
-
29
- it('should add start attribute for custom start', () => {
30
- const node: ListNode = {
31
- type: 'list',
32
- ordered: true,
33
- start: 5,
34
- children: [],
35
- }
36
-
37
- const { container } = render(<List node={node}>Items</List>)
38
- expect(container.querySelector('ol')).toHaveAttribute('start', '5')
39
- })
40
-
41
- it('should not add start attribute for default start', () => {
42
- const node: ListNode = {
43
- type: 'list',
44
- ordered: true,
45
- start: 1,
46
- children: [],
47
- }
48
-
49
- const { container } = render(<List node={node}>Items</List>)
50
- expect(container.querySelector('ol')).not.toHaveAttribute('start')
51
- })
52
- })
53
-
54
- describe('ListItem component', () => {
55
- it('should render basic list item', () => {
56
- const node: ListItemNode = {
57
- type: 'listItem',
58
- children: [],
59
- }
60
-
61
- render(<ListItem node={node}>Content</ListItem>)
62
- expect(screen.getByRole('listitem')).toHaveTextContent('Content')
63
- })
64
-
65
- it('should render checked task item', () => {
66
- const node: ListItemNode = {
67
- type: 'listItem',
68
- checked: true,
69
- children: [],
70
- }
71
-
72
- render(<ListItem node={node}>Done</ListItem>)
73
- const checkbox = screen.getByRole('checkbox')
74
- expect(checkbox).toBeChecked()
75
- })
76
-
77
- it('should render unchecked task item', () => {
78
- const node: ListItemNode = {
79
- type: 'listItem',
80
- checked: false,
81
- children: [],
82
- }
83
-
84
- render(<ListItem node={node}>Todo</ListItem>)
85
- const checkbox = screen.getByRole('checkbox')
86
- expect(checkbox).not.toBeChecked()
87
- })
88
-
89
- it('should have readonly checkbox', () => {
90
- const node: ListItemNode = {
91
- type: 'listItem',
92
- checked: false,
93
- children: [],
94
- }
95
-
96
- render(<ListItem node={node}>Todo</ListItem>)
97
- const checkbox = screen.getByRole('checkbox')
98
- expect(checkbox).toHaveAttribute('readonly')
99
- })
100
- })
@@ -1,105 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { render, screen } from '@testing-library/react'
3
- import { Table, TableRow, TableCell } from '../../src/components/defaults/Table'
4
- import type {
5
- Table as TableNode,
6
- TableRow as TableRowNode,
7
- TableCell as TableCellNode,
8
- } from 'mdast'
9
-
10
- describe('Table component', () => {
11
- it('should render table element', () => {
12
- const node: TableNode = {
13
- type: 'table',
14
- children: [],
15
- }
16
-
17
- const { container } = render(<Table node={node}>Content</Table>)
18
- expect(container.querySelector('table')).toBeInTheDocument()
19
- })
20
- })
21
-
22
- describe('TableRow component', () => {
23
- it('should render tr for body rows', () => {
24
- const node: TableRowNode = {
25
- type: 'tableRow',
26
- children: [],
27
- }
28
-
29
- const { container } = render(<TableRow node={node}>Cells</TableRow>)
30
- expect(container.querySelector('tr')).toBeInTheDocument()
31
- expect(container.querySelector('thead')).not.toBeInTheDocument()
32
- })
33
-
34
- it('should wrap header row in thead', () => {
35
- const node: TableRowNode = {
36
- type: 'tableRow',
37
- children: [],
38
- }
39
-
40
- const { container } = render(
41
- <TableRow node={node} isHeader>
42
- Cells
43
- </TableRow>
44
- )
45
- expect(container.querySelector('thead')).toBeInTheDocument()
46
- expect(container.querySelector('thead tr')).toBeInTheDocument()
47
- })
48
- })
49
-
50
- describe('TableCell component', () => {
51
- it('should render td for body cells', () => {
52
- const node: TableCellNode = {
53
- type: 'tableCell',
54
- children: [],
55
- data: { isHeader: false },
56
- }
57
-
58
- const { container } = render(<TableCell node={node}>Content</TableCell>)
59
- expect(container.querySelector('td')).toBeInTheDocument()
60
- })
61
-
62
- it('should render th for header cells', () => {
63
- const node: TableCellNode = {
64
- type: 'tableCell',
65
- children: [],
66
- data: { isHeader: true },
67
- }
68
-
69
- const { container } = render(<TableCell node={node}>Header</TableCell>)
70
- expect(container.querySelector('th')).toBeInTheDocument()
71
- })
72
-
73
- it('should apply left alignment', () => {
74
- const node: TableCellNode = {
75
- type: 'tableCell',
76
- children: [],
77
- data: { align: 'left' },
78
- }
79
-
80
- const { container } = render(<TableCell node={node}>Left</TableCell>)
81
- expect(container.querySelector('td')).toHaveStyle({ textAlign: 'left' })
82
- })
83
-
84
- it('should apply center alignment', () => {
85
- const node: TableCellNode = {
86
- type: 'tableCell',
87
- children: [],
88
- data: { align: 'center' },
89
- }
90
-
91
- const { container } = render(<TableCell node={node}>Center</TableCell>)
92
- expect(container.querySelector('td')).toHaveStyle({ textAlign: 'center' })
93
- })
94
-
95
- it('should apply right alignment', () => {
96
- const node: TableCellNode = {
97
- type: 'tableCell',
98
- children: [],
99
- data: { align: 'right' },
100
- }
101
-
102
- const { container } = render(<TableCell node={node}>Right</TableCell>)
103
- expect(container.querySelector('td')).toHaveStyle({ textAlign: 'right' })
104
- })
105
- })
@@ -1,63 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { renderHook } from '@testing-library/react'
3
- import { useMarkdown } from '../src/hooks/useMarkdown'
4
-
5
- describe('useMarkdown', () => {
6
- it('should parse markdown string', () => {
7
- const { result } = renderHook(() => useMarkdown('# Hello'))
8
-
9
- expect(result.current.type).toBe('root')
10
- expect(result.current.children[0].type).toBe('heading')
11
- })
12
-
13
- it('should memoize result for same input', () => {
14
- const { result, rerender } = renderHook(
15
- ({ source }) => useMarkdown(source),
16
- { initialProps: { source: '# Hello' } }
17
- )
18
-
19
- const firstResult = result.current
20
-
21
- rerender({ source: '# Hello' })
22
-
23
- expect(result.current).toBe(firstResult)
24
- })
25
-
26
- it('should re-parse when source changes', () => {
27
- const { result, rerender } = renderHook(
28
- ({ source }) => useMarkdown(source),
29
- { initialProps: { source: '# First' } }
30
- )
31
-
32
- expect(result.current.children[0]).toHaveProperty('type', 'heading')
33
-
34
- rerender({ source: 'Just a paragraph' })
35
-
36
- expect(result.current.children[0]).toHaveProperty('type', 'paragraph')
37
- })
38
-
39
- it('should handle empty string', () => {
40
- const { result } = renderHook(() => useMarkdown(''))
41
-
42
- expect(result.current.type).toBe('root')
43
- expect(result.current.children).toHaveLength(0)
44
- })
45
-
46
- it('should parse complex markdown', () => {
47
- const { result } = renderHook(() =>
48
- useMarkdown(`
49
- # Title
50
-
51
- Paragraph with **bold** text.
52
-
53
- - List item 1
54
- - List item 2
55
- `.trim())
56
- )
57
-
58
- expect(result.current.children).toHaveLength(3)
59
- expect(result.current.children[0].type).toBe('heading')
60
- expect(result.current.children[1].type).toBe('paragraph')
61
- expect(result.current.children[2].type).toBe('list')
62
- })
63
- })