chatgpt-to-markdown 1.5.4 → 1.5.5
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/README.md +1 -0
- package/index.js +2 -1
- package/index.test.js +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -97,6 +97,7 @@ git push --follow-tags
|
|
97
97
|
|
98
98
|
## Release notes
|
99
99
|
|
100
|
+
- 1.5.5: 02 Nov 2024. Add conversation link. Use conversation ID as fallback title if title is empty.
|
100
101
|
- 1.5.4: 02 Nov 2024. Skip `user_editable_context` to avoid polluting Markdown with custom instructions
|
101
102
|
- 1.5.3: 05 Aug 2024. Show text from multimodal prompts
|
102
103
|
- 1.5.2: 05 Aug 2024. Show tether_browsing_display summary
|
package/index.js
CHANGED
@@ -69,13 +69,14 @@ async function chatgptToMarkdown(json, sourceDir, { dateFormat } = { dateFormat:
|
|
69
69
|
}
|
70
70
|
|
71
71
|
for (const conversation of json) {
|
72
|
-
const sanitizedTitle = sanitizeFileName(conversation.title);
|
72
|
+
const sanitizedTitle = sanitizeFileName(conversation.title) || conversation.conversation_id;
|
73
73
|
const fileName = `${sanitizedTitle}.md`;
|
74
74
|
const filePath = path.join(sourceDir, fileName);
|
75
75
|
const title = `# ${wrapHtmlTagsInBackticks(conversation.title)}\n`;
|
76
76
|
const metadata = [
|
77
77
|
`- Created: ${dateFormat(new Date(conversation.create_time * 1000))}\n`,
|
78
78
|
`- Updated: ${dateFormat(new Date(conversation.update_time * 1000))}\n`,
|
79
|
+
`- Link: https://chatgpt.com/c/${conversation.conversation_id}\n`,
|
79
80
|
].join("");
|
80
81
|
const messages = Object.values(conversation.mapping)
|
81
82
|
.map((node) => {
|
package/index.test.js
CHANGED
@@ -22,6 +22,7 @@ describe("chatgptToMarkdown", () => {
|
|
22
22
|
title: "Test Conversation",
|
23
23
|
create_time: 1630454400,
|
24
24
|
update_time: 1630458000,
|
25
|
+
conversation_id: "abc123",
|
25
26
|
mapping: {
|
26
27
|
0: {
|
27
28
|
message: {
|
@@ -42,6 +43,7 @@ describe("chatgptToMarkdown", () => {
|
|
42
43
|
|
43
44
|
- Created: ${formatDate(1630454400 * 1000)}
|
44
45
|
- Updated: ${formatDate(1630458000 * 1000)}
|
46
|
+
- Link: https://chatgpt.com/c/abc123
|
45
47
|
|
46
48
|
## user (John)
|
47
49
|
|
@@ -360,4 +362,19 @@ describe("chatgptToMarkdown", () => {
|
|
360
362
|
await expect(chatgptToMarkdown("not an array", tempDir)).rejects.toThrow(TypeError);
|
361
363
|
await expect(chatgptToMarkdown([], 123)).rejects.toThrow(TypeError);
|
362
364
|
});
|
365
|
+
|
366
|
+
it("should use conversation_id as filename when sanitized title is empty", async () => {
|
367
|
+
const json = [
|
368
|
+
{
|
369
|
+
title: "?????", // Will be sanitized to empty string
|
370
|
+
conversation_id: "abc123",
|
371
|
+
create_time: 1630454400,
|
372
|
+
update_time: 1630458000,
|
373
|
+
mapping: {},
|
374
|
+
},
|
375
|
+
];
|
376
|
+
|
377
|
+
await chatgptToMarkdown(json, tempDir);
|
378
|
+
await expect(fs.access(path.join(tempDir, "abc123.md"))).resolves.not.toThrow();
|
379
|
+
});
|
363
380
|
});
|