@celhive/tool.js 0.0.5 → 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.
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/lib/{mendMarkdown.d.ts → markdown-patch.d.ts} +1 -1
- package/lib/{mendMarkdown.js → markdown-patch.js} +32 -4
- package/package.json +3 -2
- /package/lib/{getPDFViewerUrl.d.ts → get-pdf-viewer-urll.d.ts} +0 -0
- /package/lib/{getPDFViewerUrl.js → get-pdf-viewer-urll.js} +0 -0
- /package/lib/{mockStream.d.ts → mock-stream.d.ts} +0 -0
- /package/lib/{mockStream.js → mock-stream.js} +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './formatCitation';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
2
|
+
export * from './get-pdf-viewer-urll';
|
|
3
|
+
export * from './markdown-patch';
|
|
4
|
+
export * from './mock-stream';
|
|
5
5
|
export * from './token-exceeded';
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./formatCitation"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./get-pdf-viewer-urll"), exports);
|
|
19
|
+
__exportStar(require("./markdown-patch"), exports);
|
|
20
|
+
__exportStar(require("./mock-stream"), exports);
|
|
21
21
|
__exportStar(require("./token-exceeded"), exports);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.markdownPatch = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 修复 markdown 格式缺失问题
|
|
6
6
|
* @param md - 需要修复的 markdown 字符串
|
|
7
7
|
* @returns string 修复后的 markdown 字符串
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const markdownPatch = (md) => {
|
|
10
10
|
const lines = md.split('\n');
|
|
11
11
|
let inCodeBlock = false;
|
|
12
12
|
const mendTitle = lines
|
|
@@ -40,7 +40,35 @@ const mendMarkdown = (md) => {
|
|
|
40
40
|
: match;
|
|
41
41
|
});
|
|
42
42
|
// 写一个正则,如果 ```mermaid 前面只有一个换行符,就添加一个换行符
|
|
43
|
-
const
|
|
43
|
+
const mendMermaid = mendBold.replace(/(\n)```mermaid/g, '$1\n```mermaid');
|
|
44
|
+
// 在连续的 # 符号(1个以上)前面插入换行符,但不处理行首的 #
|
|
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');
|
|
44
72
|
return result;
|
|
45
73
|
};
|
|
46
|
-
exports.
|
|
74
|
+
exports.markdownPatch = markdownPatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celhive/tool.js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"test": "vitest --coverage run",
|
|
13
13
|
"doc": "typedoc",
|
|
14
14
|
"watch-doc": "onchange 'src/**/*.ts' './README.md' -- npm run doc",
|
|
15
|
-
"watch-preview": "live-server doc"
|
|
15
|
+
"watch-preview": "live-server doc",
|
|
16
|
+
"deploy-doc": "pnpm build && rsync -avz --delete doc/ twitter:/usr/share/nginx/tool.js --rsync-path='sudo rsync'"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"concurrently": "^8.2.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|