@celhive/tool.js 0.0.6 → 0.0.7

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.
@@ -42,7 +42,33 @@ const markdownPatch = (md) => {
42
42
  // 写一个正则,如果 ```mermaid 前面只有一个换行符,就添加一个换行符
43
43
  const mendMermaid = mendBold.replace(/(\n)```mermaid/g, '$1\n```mermaid');
44
44
  // 在连续的 # 符号(1个以上)前面插入换行符,但不处理行首的 #
45
- const result = mendMermaid.replace(/([^\n#])(#{2,})/g, '$1\n$2');
45
+ const mendHashNewline = mendMermaid.replace(/([^\n#])(#{2,})/g, '$1\n$2');
46
+ // 再次处理新行中的标题格式,确保 # 和内容之间有空格
47
+ const lines2 = mendHashNewline.split('\n');
48
+ let inCodeBlock2 = false;
49
+ const result = lines2
50
+ .map((line) => {
51
+ // 检查是否是代码块的开始或结束
52
+ if (line.trim().startsWith('```')) {
53
+ inCodeBlock2 = !inCodeBlock2;
54
+ return line;
55
+ }
56
+ // 如果在代码块内,跳过处理
57
+ if (inCodeBlock2) {
58
+ return line;
59
+ }
60
+ const match = line.match(/^(\s*)(#+)(\s*)(.*)$/);
61
+ if (match) {
62
+ const [, leadingSpaces, hashes, spaces, content] = match;
63
+ if (hashes.length > 0 &&
64
+ spaces.length === 0 &&
65
+ !content.startsWith('#')) {
66
+ return `${leadingSpaces}${hashes} ${content}`;
67
+ }
68
+ }
69
+ return line;
70
+ })
71
+ .join('\n');
46
72
  return result;
47
73
  };
48
74
  exports.markdownPatch = markdownPatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celhive/tool.js",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"