ds-markdown 0.2.4-beta.1 → 0.2.4-beta.2

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 (159) hide show
  1. package/es/AutoScroll/index.d.ts +7 -0
  2. package/es/AutoScroll/index.d.ts.map +1 -0
  3. package/es/AutoScroll/index.js +7 -0
  4. package/es/AutoScroll/index.js.map +1 -0
  5. package/es/Markdown/index.d.ts +5 -0
  6. package/es/Markdown/index.d.ts.map +1 -0
  7. package/es/Markdown/index.js +78 -0
  8. package/es/Markdown/index.js.map +1 -0
  9. package/es/MarkdownCMD/index.d.ts +13 -0
  10. package/es/MarkdownCMD/index.d.ts.map +1 -0
  11. package/es/MarkdownCMD/index.js +122 -0
  12. package/es/MarkdownCMD/index.js.map +1 -0
  13. package/es/components/CodeComponent/BlockWrap/index.css +64 -0
  14. package/es/components/CodeComponent/BlockWrap/index.d.ts +10 -0
  15. package/es/components/CodeComponent/BlockWrap/index.d.ts.map +1 -0
  16. package/es/components/CodeComponent/BlockWrap/index.js +20 -0
  17. package/es/components/CodeComponent/BlockWrap/index.js.map +1 -0
  18. package/es/components/CodeComponent/CodeBlockActions/index.d.ts +8 -0
  19. package/es/components/CodeComponent/CodeBlockActions/index.d.ts.map +1 -0
  20. package/es/components/CodeComponent/CodeBlockActions/index.js +8 -0
  21. package/es/components/CodeComponent/CodeBlockActions/index.js.map +1 -0
  22. package/es/components/CodeComponent/CodeBlockWrap/index.d.ts +8 -0
  23. package/es/components/CodeComponent/CodeBlockWrap/index.d.ts.map +1 -0
  24. package/es/components/CodeComponent/CodeBlockWrap/index.js +8 -0
  25. package/es/components/CodeComponent/CodeBlockWrap/index.js.map +1 -0
  26. package/es/components/CodeComponent/HighlightCode/index.d.ts +8 -0
  27. package/es/components/CodeComponent/HighlightCode/index.d.ts.map +1 -0
  28. package/es/components/CodeComponent/HighlightCode/index.js +7 -0
  29. package/es/components/CodeComponent/HighlightCode/index.js.map +1 -0
  30. package/es/components/CodeComponent/index.css +551 -0
  31. package/es/components/CodeComponent/index.d.ts +8 -0
  32. package/es/components/CodeComponent/index.d.ts.map +1 -0
  33. package/es/components/CodeComponent/index.js +11 -0
  34. package/es/components/CodeComponent/index.js.map +1 -0
  35. package/es/components/CopyButton/index.d.ts +9 -0
  36. package/es/components/CopyButton/index.d.ts.map +1 -0
  37. package/es/components/CopyButton/index.js +24 -0
  38. package/es/components/CopyButton/index.js.map +1 -0
  39. package/es/components/DownloadButton/index.d.ts +10 -0
  40. package/es/components/DownloadButton/index.d.ts.map +1 -0
  41. package/es/components/DownloadButton/index.js +61 -0
  42. package/es/components/DownloadButton/index.js.map +1 -0
  43. package/es/components/Icon/index.d.ts +12 -0
  44. package/es/components/Icon/index.d.ts.map +1 -0
  45. package/es/components/Icon/index.js +12 -0
  46. package/es/components/Icon/index.js.map +1 -0
  47. package/es/components/TableComponent/index.css +24 -0
  48. package/es/components/TableComponent/index.d.ts +8 -0
  49. package/es/components/TableComponent/index.d.ts.map +1 -0
  50. package/es/components/TableComponent/index.js +7 -0
  51. package/es/components/TableComponent/index.js.map +1 -0
  52. package/es/components/ui/Button/index.d.ts +12 -0
  53. package/es/components/ui/Button/index.d.ts.map +1 -0
  54. package/es/components/ui/Button/index.js +17 -0
  55. package/es/components/ui/Button/index.js.map +1 -0
  56. package/es/components/ui/IconButton/index.d.ts +9 -0
  57. package/es/components/ui/IconButton/index.d.ts.map +1 -0
  58. package/es/components/ui/IconButton/index.js +7 -0
  59. package/es/components/ui/IconButton/index.js.map +1 -0
  60. package/es/components/ui/Segmented/index.css +35 -0
  61. package/es/components/ui/Segmented/index.d.ts +14 -0
  62. package/es/components/ui/Segmented/index.d.ts.map +1 -0
  63. package/es/components/ui/Segmented/index.js +10 -0
  64. package/es/components/ui/Segmented/index.js.map +1 -0
  65. package/es/components/ui/SuccessButton/index.d.ts +11 -0
  66. package/es/components/ui/SuccessButton/index.d.ts.map +1 -0
  67. package/es/components/ui/SuccessButton/index.js +46 -0
  68. package/es/components/ui/SuccessButton/index.js.map +1 -0
  69. package/es/constant.d.ts +6 -0
  70. package/es/constant.d.ts.map +1 -0
  71. package/es/constant.js +7 -0
  72. package/es/constant.js.map +1 -0
  73. package/es/context/ConfigProvider/index.d.ts +40 -0
  74. package/es/context/ConfigProvider/index.d.ts.map +1 -0
  75. package/es/context/ConfigProvider/index.js +32 -0
  76. package/es/context/ConfigProvider/index.js.map +1 -0
  77. package/es/context/MarkdownProvider.d.ts +9 -0
  78. package/es/context/MarkdownProvider.d.ts.map +1 -0
  79. package/es/context/MarkdownProvider.js +10 -0
  80. package/es/context/MarkdownProvider.js.map +1 -0
  81. package/es/context/MarkdownThemeProvider.d.ts +21 -0
  82. package/es/context/MarkdownThemeProvider.d.ts.map +1 -0
  83. package/es/context/MarkdownThemeProvider.js +31 -0
  84. package/es/context/MarkdownThemeProvider.js.map +1 -0
  85. package/es/defined/index.d.ts +75 -0
  86. package/es/defined/index.d.ts.map +1 -0
  87. package/es/defined/index.js +3 -0
  88. package/es/defined/index.js.map +1 -0
  89. package/{dist/cjs/index.d.ts → es/defined/mermaid.type.d.ts} +6 -234
  90. package/es/defined/mermaid.type.d.ts.map +1 -0
  91. package/es/defined/mermaid.type.js +2 -0
  92. package/es/defined/mermaid.type.js.map +1 -0
  93. package/es/defined.css +481 -0
  94. package/{dist/cjs → es}/i18n/en/index.d.ts +4 -5
  95. package/es/i18n/en/index.d.ts.map +1 -0
  96. package/{dist/esm → es}/i18n/en/index.js +4 -4
  97. package/es/i18n/en/index.js.map +1 -0
  98. package/es/i18n/index.d.ts +7 -0
  99. package/es/i18n/index.d.ts.map +1 -0
  100. package/es/i18n/index.js +7 -0
  101. package/es/i18n/index.js.map +1 -0
  102. package/{dist/esm/i18n/en → es/i18n/zh}/index.d.ts +5 -6
  103. package/es/i18n/zh/index.d.ts.map +1 -0
  104. package/{dist/esm → es}/i18n/zh/index.js +4 -4
  105. package/es/i18n/zh/index.js.map +1 -0
  106. package/es/index.css +330 -0
  107. package/es/index.d.ts +23 -0
  108. package/es/index.d.ts.map +1 -0
  109. package/es/index.js +21 -0
  110. package/es/index.js.map +1 -0
  111. package/es/plugins/index.d.ts +6 -0
  112. package/es/plugins/index.d.ts.map +1 -0
  113. package/{dist/esm → es}/plugins/index.js +3 -11
  114. package/es/plugins/index.js.map +1 -0
  115. package/es/utils/Tokenizer.d.ts +48 -0
  116. package/es/utils/Tokenizer.d.ts.map +1 -0
  117. package/es/utils/Tokenizer.js +191 -0
  118. package/es/utils/Tokenizer.js.map +1 -0
  119. package/es/utils/compiler.d.ts +5 -0
  120. package/es/utils/compiler.d.ts.map +1 -0
  121. package/es/utils/compiler.js +62 -0
  122. package/es/utils/compiler.js.map +1 -0
  123. package/es/utils/grapheme.d.ts +2 -0
  124. package/es/utils/grapheme.d.ts.map +1 -0
  125. package/es/utils/grapheme.js +4 -0
  126. package/es/utils/grapheme.js.map +1 -0
  127. package/es/utils/methods/deepClone.d.ts +2 -0
  128. package/es/utils/methods/deepClone.d.ts.map +1 -0
  129. package/es/utils/methods/deepClone.js +4 -0
  130. package/es/utils/methods/deepClone.js.map +1 -0
  131. package/es/utils/remarkMathBracket.d.ts +21 -0
  132. package/es/utils/remarkMathBracket.d.ts.map +1 -0
  133. package/es/utils/remarkMathBracket.js +49 -0
  134. package/es/utils/remarkMathBracket.js.map +1 -0
  135. package/es/utils/rule.d.ts +26 -0
  136. package/es/utils/rule.d.ts.map +1 -0
  137. package/es/utils/rule.js +69 -0
  138. package/es/utils/rule.js.map +1 -0
  139. package/package.json +2 -2
  140. package/dist/cjs/i18n/en/index.js +0 -30
  141. package/dist/cjs/i18n/en/index.js.map +0 -1
  142. package/dist/cjs/i18n/zh/index.d.ts +0 -26
  143. package/dist/cjs/i18n/zh/index.js +0 -30
  144. package/dist/cjs/i18n/zh/index.js.map +0 -1
  145. package/dist/cjs/index.js +0 -1106
  146. package/dist/cjs/index.js.map +0 -1
  147. package/dist/cjs/plugins/index.d.ts +0 -20
  148. package/dist/cjs/plugins/index.js +0 -30
  149. package/dist/cjs/plugins/index.js.map +0 -1
  150. package/dist/esm/i18n/en/index.js.map +0 -1
  151. package/dist/esm/i18n/zh/index.d.ts +0 -26
  152. package/dist/esm/i18n/zh/index.js.map +0 -1
  153. package/dist/esm/index.d.ts +0 -1747
  154. package/dist/esm/index.js +0 -1084
  155. package/dist/esm/index.js.map +0 -1
  156. package/dist/esm/plugins/index.d.ts +0 -20
  157. package/dist/esm/plugins/index.js.map +0 -1
  158. /package/{dist → es}/katex.css +0 -0
  159. /package/{dist → es}/style.css +0 -0
@@ -0,0 +1,5 @@
1
+ import { Token } from './Tokenizer';
2
+ declare function createCompiler(src: string): Token[];
3
+ export declare const compiler: typeof createCompiler;
4
+ export {};
5
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/utils/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAa,MAAM,aAAa,CAAC;AA8D3D,iBAAS,cAAc,CAAC,GAAG,EAAE,MAAM,WAGlC;AAED,eAAO,MAAM,QAAQ,uBAAiB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { getTokenId, Tokenizer } from './Tokenizer.js';
2
+ function compile(src) {
3
+ const tokenizer = new Tokenizer();
4
+ const tokens = [];
5
+ let prevScr = src;
6
+ while (src) {
7
+ if (src.length === 0) {
8
+ break;
9
+ }
10
+ // TODO: 临时方案
11
+ if (src.trim().length === 0 && tokens.length > 0) {
12
+ const lastToken = tokens[tokens.length - 1];
13
+ // 如果只剩下空格或换行符,则加到上一个token中
14
+ if (lastToken.type === 'list') {
15
+ lastToken.raw = lastToken.raw + src;
16
+ break;
17
+ }
18
+ }
19
+ const space = tokenizer.space(src);
20
+ if (space) {
21
+ tokens.push(space);
22
+ src = src.slice(space.raw.length);
23
+ continue;
24
+ }
25
+ const list = tokenizer.list(src);
26
+ if (list) {
27
+ tokens.push(list);
28
+ src = src.slice(list.raw.length);
29
+ continue;
30
+ }
31
+ const fence = tokenizer.fence(src);
32
+ if (fence) {
33
+ tokens.push(fence);
34
+ src = src.slice(fence.raw.length);
35
+ continue;
36
+ }
37
+ const segment = tokenizer.segment(src);
38
+ if (segment) {
39
+ tokens.push(segment);
40
+ src = src.slice(segment.raw.length);
41
+ continue;
42
+ }
43
+ if (prevScr === src && src) {
44
+ // 如果src没有变化,则认为是一个段落
45
+ // todo: 后面会做优化,进行细分
46
+ tokens.push({
47
+ type: 'segment',
48
+ raw: src,
49
+ id: getTokenId(),
50
+ });
51
+ src = '';
52
+ }
53
+ prevScr = src;
54
+ }
55
+ return tokens;
56
+ }
57
+ function createCompiler(src) {
58
+ const tokens = compile(src);
59
+ return tokens;
60
+ }
61
+ export const compiler = createCompiler;
62
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/utils/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAS,SAAS,EAAE,MAAM,aAAa,CAAC;AAE3D,SAAS,OAAO,CAAC,GAAW;IAC1B,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAElC,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAG,GAAG,CAAC;IAElB,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM;QACR,CAAC;QAED,aAAa;QACb,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAC5C,2BAA2B;YAC3B,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC9B,SAAS,CAAC,GAAG,GAAG,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ACR,EAAE,EAAE,UAAU,EAAE;aACjB,CAAC,CAAC;YACH,GAAG,GAAG,EAAE,CAAC;QACX,CAAC;QACD,OAAO,GAAG,GAAG,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function splitGraphemes(input: string): string[];
2
+ //# sourceMappingURL=grapheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grapheme.d.ts","sourceRoot":"","sources":["../../src/utils/grapheme.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtD"}
@@ -0,0 +1,4 @@
1
+ export function splitGraphemes(input) {
2
+ return Array.from(input);
3
+ }
4
+ //# sourceMappingURL=grapheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grapheme.js","sourceRoot":"","sources":["../../src/utils/grapheme.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default function deepClone<T>(obj: T): T;
2
+ //# sourceMappingURL=deepClone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepClone.d.ts","sourceRoot":"","sources":["../../../src/utils/methods/deepClone.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAE9C"}
@@ -0,0 +1,4 @@
1
+ export default function deepClone(obj) {
2
+ return JSON.parse(JSON.stringify(obj));
3
+ }
4
+ //# sourceMappingURL=deepClone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepClone.js","sourceRoot":"","sources":["../../../src/utils/methods/deepClone.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAI,GAAM;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Plugin } from 'unified';
2
+ /**
3
+ * remark 插件:将 \[...\] 转换为 $$...$$,\(...\) 转换为 $...$,以便 remark-math 能识别。
4
+ */
5
+ declare const remarkMathBracket: Plugin;
6
+ /**
7
+ * 将括号格式的数学公式转换为美元符号格式
8
+ * 支持以下转换:
9
+ * - \(...\) → $...$ (行内公式)
10
+ * - \[...\] → $$...$$ (块级公式)
11
+ *
12
+ * 特殊处理:
13
+ * - 如果文本包含 Markdown 超链接,则跳过转换以避免误处理
14
+ * - 使用占位符机制保护块级公式内的括号不被误转换
15
+ *
16
+ * @param value 要转换的字符串
17
+ * @returns 转换后的字符串
18
+ */
19
+ export declare const replaceMathBracket: (value: string) => string;
20
+ export default remarkMathBracket;
21
+ //# sourceMappingURL=remarkMathBracket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remarkMathBracket.d.ts","sourceRoot":"","sources":["../../src/utils/remarkMathBracket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC;;GAEG;AACH,QAAA,MAAM,iBAAiB,EAAE,MAQxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,WAyB/C,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { visit } from 'unist-util-visit';
2
+ /**
3
+ * remark 插件:将 \[...\] 转换为 $$...$$,\(...\) 转换为 $...$,以便 remark-math 能识别。
4
+ */
5
+ const remarkMathBracket = () => (tree, file) => {
6
+ visit(tree, 'text', (node) => {
7
+ const value = node.value;
8
+ if (typeof value === 'string') {
9
+ node.value = replaceMathBracket(value);
10
+ }
11
+ });
12
+ };
13
+ /**
14
+ * 将括号格式的数学公式转换为美元符号格式
15
+ * 支持以下转换:
16
+ * - \(...\) → $...$ (行内公式)
17
+ * - \[...\] → $$...$$ (块级公式)
18
+ *
19
+ * 特殊处理:
20
+ * - 如果文本包含 Markdown 超链接,则跳过转换以避免误处理
21
+ * - 使用占位符机制保护块级公式内的括号不被误转换
22
+ *
23
+ * @param value 要转换的字符串
24
+ * @returns 转换后的字符串
25
+ */
26
+ export const replaceMathBracket = (value) => {
27
+ // 1. 提取所有块级公式内容,临时替换为占位符, [...]
28
+ const blockMatches = [];
29
+ let replaced = value.replace(/\\+\[([\s\S]+?)\\+\]/g, (_m, p1) => {
30
+ blockMatches.push(p1);
31
+ return `__BLOCK_MATH_${blockMatches.length - 1}__`;
32
+ });
33
+ // 也需要兼容 $$ xxxx $$ 这种写法
34
+ replaced = replaced.replace(/\$\$([\s\S]+?)\$\$/g, (_m, p1) => {
35
+ blockMatches.push(p1);
36
+ return `__BLOCK_MATH_${blockMatches.length - 1}__`;
37
+ });
38
+ // 2. 替换块级公式外部的 ( ... ) 为 $...$
39
+ replaced = replaced.replace(/\\+\(([^)]+?)\\+\)/g, (_m, p1) => {
40
+ return '$' + p1 + '$';
41
+ });
42
+ // 3. 还原块级公式内容,保持其内部小括号原样
43
+ replaced = replaced.replace(/__BLOCK_MATH_(\d+)__/g, (_m, idx) => {
44
+ return '$$' + blockMatches[Number(idx)] + '$$';
45
+ });
46
+ return replaced;
47
+ };
48
+ export default remarkMathBracket;
49
+ //# sourceMappingURL=remarkMathBracket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remarkMathBracket.js","sourceRoot":"","sources":["../../src/utils/remarkMathBracket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC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uBAAuB,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;QAC/D,OAAO,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,26 @@
1
+ /** 此文件借鉴 marked 的部分代码 */
2
+ export declare const rules: {
3
+ block: {
4
+ newline: RegExp;
5
+ fences: RegExp;
6
+ segment: RegExp;
7
+ list: RegExp;
8
+ hr: RegExp;
9
+ };
10
+ other: {
11
+ caret: RegExp;
12
+ listItemRegex: (bull: string) => RegExp;
13
+ nextBulletRegex: (indent: number) => RegExp;
14
+ listReplaceTabs: RegExp;
15
+ nonSpaceChar: RegExp;
16
+ blankLine: RegExp;
17
+ listIsTask: RegExp;
18
+ listReplaceTask: RegExp;
19
+ tabCharGlobal: RegExp;
20
+ hrRegex: (indent: number) => RegExp;
21
+ headingBeginRegex: (indent: number) => RegExp;
22
+ htmlBeginRegex: (indent: number) => RegExp;
23
+ fencesBeginRegex: (indent: number) => RegExp;
24
+ };
25
+ };
26
+ //# sourceMappingURL=rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../src/utils/rule.ts"],"names":[],"mappings":"AAAA,yBAAyB;AAuEzB,eAAO,MAAM,KAAK;;;;;;;;;;8BAnEM,MAAM;kCACF,MAAM;;;;;;;0BAOd,MAAM;oCACI,MAAM;iCACT,MAAM;mCACJ,MAAM;;CA2DlC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /** 此文件借鉴 marked 的部分代码 */
2
+ const other = {
3
+ caret: /(^|[^[])\^/g,
4
+ listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`),
5
+ nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),
6
+ listReplaceTabs: /^\t+/,
7
+ nonSpaceChar: /[^ ]/,
8
+ blankLine: /^[ \t]*$/,
9
+ listIsTask: /^\[[ xX]\] /,
10
+ listReplaceTask: /^\[[ xX]\] +/,
11
+ tabCharGlobal: /\t/g,
12
+ hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
13
+ headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
14
+ htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, 'i'),
15
+ fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
16
+ };
17
+ /**
18
+ * 编辑正则表达式
19
+ * @param regex 正则表达式
20
+ * @param opt 正则表达式选项
21
+ * @returns 编辑后的正则表达式
22
+ */
23
+ function edit(regex, opt = '') {
24
+ let source = typeof regex === 'string' ? regex : regex.source;
25
+ const obj = {
26
+ replace: (name, val) => {
27
+ let valSource = typeof val === 'string' ? val : val.source;
28
+ valSource = valSource.replace(other.caret, '$1');
29
+ source = source.replace(name, valSource);
30
+ return obj;
31
+ },
32
+ getRegex: () => {
33
+ return new RegExp(source, opt);
34
+ },
35
+ };
36
+ return obj;
37
+ }
38
+ const newline = /^(?:[ \t]*(?:\n|$))+/;
39
+ const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
40
+ /** 列表 */
41
+ const bullet = /(?:[*+-]|\d{1,9}[.)])/;
42
+ /** 列表 */
43
+ const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
44
+ .replace(/bull/g, bullet)
45
+ .getRegex();
46
+ /** 围栏 fence
47
+ * 什么是围栏: 围栏是用来包裹代码块的,比如 ```javascript 和 ``` 之间就是围栏
48
+ */
49
+ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
50
+ // 一个块
51
+ // const _segment = /^([^\n]+(?:\n(?!fences|list|hr| +\n)[^\n]+)*)/;
52
+ const _segment = /^([^\n]+(?:\n(?!fences|list|hr| +\n|\n)[^\n]+)*\n?)/;
53
+ const segment = edit(_segment)
54
+ .replace(/fences/, fences)
55
+ .replace(/list/, list)
56
+ .replace(/hr/, hr)
57
+ .getRegex();
58
+ const blockNormal = {
59
+ newline,
60
+ fences,
61
+ segment,
62
+ list,
63
+ hr,
64
+ };
65
+ export const rules = {
66
+ block: blockNormal,
67
+ other,
68
+ };
69
+ //# sourceMappingURL=rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.js","sourceRoot":"","sources":["../../src/utils/rule.ts"],"names":[],"mappings":"AAAA,yBAAyB;AAEzB,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,aAAa;IACpB,aAAa,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,IAAI,+BAA+B,CAAC;IAC3F,eAAe,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,qDAAqD,CAAC;IACrI,eAAe,EAAE,MAAM;IACvB,YAAY,EAAE,MAAM;IACpB,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,aAAa;IACzB,eAAe,EAAE,cAAc;IAC/B,aAAa,EAAE,KAAK;IACpB,OAAO,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,oDAAoD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CAAC;AACvC,MAAM,EAAE,GAAG,oEAAoE,CAAC;AAChF,SAAS;AACT,MAAM,MAAM,GAAG,uBAAuB,CAAC;AACvC,SAAS;AACT,MAAM,IAAI,GAAG,IAAI,CAAC,sCAAsC,CAAC;KACtD,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC;KACxB,QAAQ,EAAE,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,GAAG,6GAA6G,CAAC;AAC7H,MAAM;AACN,oEAAoE;AACpE,MAAM,QAAQ,GAAG,qDAAqD,CAAC;AAEvE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;KAC3B,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;KACzB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;KACrB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;KACjB,QAAQ,EAAE,CAAC;AAEd,MAAM,WAAW,GAAG;IAClB,OAAO;IACP,MAAM;IACN,OAAO;IACP,IAAI;IACJ,EAAE;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,WAAW;IAClB,KAAK;CACN,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ds-markdown",
3
3
  "private": false,
4
- "version": "0.2.4-beta.1",
4
+ "version": "0.2.4-beta.2",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",
7
7
  "module": "./dist/esm/index.js",
@@ -61,7 +61,7 @@
61
61
  }
62
62
  },
63
63
  "files": [
64
- "dist"
64
+ "es"
65
65
  ],
66
66
  "scripts": {
67
67
  "dev": "vite",
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const enUS = {
6
- codeBlock: {
7
- copy: 'Copy',
8
- copied: 'Copied',
9
- download: 'Download',
10
- downloaded: 'Downloaded',
11
- },
12
- mermaid: {
13
- diagram: 'Diagram',
14
- code: 'Code',
15
- zoomOut: 'Zoom Out',
16
- zoomIn: 'Zoom In',
17
- download: 'Download',
18
- fullScreen: 'Full Screen',
19
- exitFullScreen: 'Exit Full Screen',
20
- downloadImage: 'Download Image',
21
- downloadedImage: 'Downloaded',
22
- copiedImage: 'Copied',
23
- copyImage: 'Copy Image',
24
- fitInView: 'Fit in view',
25
- },
26
- };
27
-
28
- exports.default = enUS;
29
- exports.enUS = enUS;
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/i18n/en/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAa,MAAA,IAAI,GAAG;AAClB,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,MAAM,EAAE,QAAQ;AAChB,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,UAAU,EAAE,YAAY;AACzB,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,OAAO,EAAE,UAAU;AACnB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,UAAU,EAAE,aAAa;AACzB,QAAA,cAAc,EAAE,kBAAkB;AAClC,QAAA,aAAa,EAAE,gBAAgB;AAC/B,QAAA,eAAe,EAAE,YAAY;AAC7B,QAAA,WAAW,EAAE,QAAQ;AACrB,QAAA,SAAS,EAAE,YAAY;AACvB,QAAA,SAAS,EAAE,aAAa;AACzB,KAAA;;;;;;"}
@@ -1,26 +0,0 @@
1
- declare const zhCN: {
2
- codeBlock: {
3
- copy: string;
4
- copied: string;
5
- download: string;
6
- downloaded: string;
7
- };
8
- mermaid: {
9
- diagram: string;
10
- code: string;
11
- zoomOut: string;
12
- zoomIn: string;
13
- download: string;
14
- fullScreen: string;
15
- exitFullScreen: string;
16
- downloadImage: string;
17
- downloadedImage: string;
18
- copyImage: string;
19
- copiedImage: string;
20
- fitInView: string;
21
- };
22
- };
23
- type ZhCN = typeof zhCN;
24
-
25
- export { zhCN as default, zhCN };
26
- export type { ZhCN };
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const zhCN = {
6
- codeBlock: {
7
- copy: '复制',
8
- copied: '已复制',
9
- download: '下载',
10
- downloaded: '已下载',
11
- },
12
- mermaid: {
13
- diagram: '图表',
14
- code: '代码',
15
- zoomOut: '缩小',
16
- zoomIn: '放大',
17
- download: '下载',
18
- fullScreen: '全屏',
19
- exitFullScreen: '退出全屏',
20
- downloadImage: '下载图片',
21
- downloadedImage: '已下载',
22
- copyImage: '复制图片',
23
- copiedImage: '已复制',
24
- fitInView: '适应页面',
25
- },
26
- };
27
-
28
- exports.default = zhCN;
29
- exports.zhCN = zhCN;
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/i18n/zh/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAa,MAAA,IAAI,GAAG;AAClB,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,UAAU,EAAE,KAAK;AAClB,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,UAAU,EAAE,IAAI;AAChB,QAAA,cAAc,EAAE,MAAM;AACtB,QAAA,aAAa,EAAE,MAAM;AACrB,QAAA,eAAe,EAAE,KAAK;AACtB,QAAA,SAAS,EAAE,MAAM;AACjB,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,SAAS,EAAE,MAAM;AAClB,KAAA;;;;;;"}