chatgpt-to-markdown 1.5.0 → 1.5.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.
- package/README.md +1 -0
- package/index.js +19 -18
- package/package.json +2 -2
package/README.md
CHANGED
@@ -97,6 +97,7 @@ git push --follow-tags
|
|
97
97
|
|
98
98
|
## Release notes
|
99
99
|
|
100
|
+
- 1.5.1: 22 Mar 2024. Handle unicode filenames
|
100
101
|
- 1.5.0: 28 Nov 2023. Handle `tether_browsing_display`, `tether_quote` and `system_error`
|
101
102
|
- 1.4.0: 29 Oct 2023. Handle multi-modal text from Dall-E
|
102
103
|
- 1.3.0: 29 Sep 2023. Set create and update dates from chat
|
package/index.js
CHANGED
@@ -9,6 +9,7 @@ import path from "path";
|
|
9
9
|
function sanitizeFileName(title) {
|
10
10
|
return title
|
11
11
|
.replace(/[<>:"\/\\|?*\n]/g, " ")
|
12
|
+
.replace(/[^\w\s]/gi, " ")
|
12
13
|
.replace(/\s+/g, " ")
|
13
14
|
.trim();
|
14
15
|
}
|
@@ -85,24 +86,24 @@ async function chatgptToMarkdown(json, sourceDir, { dateFormat } = { dateFormat:
|
|
85
86
|
content.content_type == "text"
|
86
87
|
? content.parts.join("\n")
|
87
88
|
: content.content_type == "code"
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
89
|
+
? "```" + content.language.replace("unknown", "") + "\n" + content.text + "\n```"
|
90
|
+
: content.content_type == "execution_output"
|
91
|
+
? "```\n" + content.text + "\n```"
|
92
|
+
: content.content_type == "multimodal_text"
|
93
|
+
? content.parts
|
94
|
+
.map((part) =>
|
95
|
+
part.content_type === "image_asset_pointer"
|
96
|
+
? `Image (${part.width}x${part.height}): ${part?.metadata?.dalle?.prompt}\n\n`
|
97
|
+
: `${part.content_type}\n\n`,
|
98
|
+
)
|
99
|
+
.join("")
|
100
|
+
: content.content_type == "tether_browsing_display"
|
101
|
+
? "```\n" + content.result + "\n```"
|
102
|
+
: content.content_type == "tether_quote"
|
103
|
+
? "```\n" + `${content.title} (${content.url})\n\n${content.text}` + "\n```"
|
104
|
+
: content.content_type == "system_error"
|
105
|
+
? `${content.name}\n\n${content.text}\n\n`
|
106
|
+
: content;
|
106
107
|
// Ignore empty content
|
107
108
|
if (!body.trim()) return "";
|
108
109
|
// Indent user / tool messages. The sometimes contain code and whitespaces are relevant
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "chatgpt-to-markdown",
|
3
|
-
"version": "1.5.
|
3
|
+
"version": "1.5.1",
|
4
4
|
"description": "Convert ChatGPT exported conversations.json to Markdown",
|
5
5
|
"main": "index.js",
|
6
6
|
"type": "module",
|
@@ -23,6 +23,6 @@
|
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
25
|
"jest": "^29.7.0",
|
26
|
-
"prettier": "^3.
|
26
|
+
"prettier": "^3.2.5"
|
27
27
|
}
|
28
28
|
}
|