chatgpt-to-markdown 1.8.0 → 1.9.0

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 CHANGED
@@ -18,6 +18,7 @@ npx chatgpt-to-markdown path/to/your/conversations.json
18
18
  **NO NEED TO INSTALL** - `npx` will automatically install the package if it's not already installed.
19
19
 
20
20
  This will generate one Markdown file for each chat same directory as the conversations JSON file. The file name will be the chat title, with invalid filename characters replaced by spaces.
21
+ Duplicate titles get ` (1)`, ` (2)` suffixes to keep names unique.
21
22
 
22
23
  For example, the Markdown output for a chat with the title `Medium-Style Table CSS` might look like this:
23
24
 
@@ -109,6 +110,7 @@ git commit . -m"$COMMIT_MSG"; git tag $VERSION; git push --follow-tags
109
110
 
110
111
  ## Release notes
111
112
 
113
+ - [1.9.0](https://npmjs.com/package/chatgpt-to-markdown/v/1.9.0): 31 Jul 2025. Append numeric suffixes for duplicate chat titles
112
114
  - [1.8.0](https://npmjs.com/package/chatgpt-to-markdown/v/1.8.0): 30 Jul 2025. Standardized package.json & README.md
113
115
  - [1.7.1](https://npmjs.com/package/chatgpt-to-markdown/v/1.7.1): 29 Jun 2025. Add thinktime analysis tool as npx executable. Analyze thinking/reasoning time statistics from ChatGPT conversations
114
116
  - [1.6.0](https://npmjs.com/package/chatgpt-to-markdown/v/1.6.0): 18 Jun 2025. Handle `thoughts`, `reasoning_recap`, `sonic_webpage`. Include projects
@@ -129,16 +129,15 @@ export const formatDate = (date) => dateFormat.format(date);
129
129
  * //=> Creates a markdown file for each conversation in the output directory
130
130
  */
131
131
  async function chatgptToMarkdown(json, sourceDir, { dateFormat } = { dateFormat: formatDate }) {
132
- if (!Array.isArray(json)) {
133
- throw new TypeError("The first argument must be an array.");
134
- }
135
- if (typeof sourceDir !== "string") {
136
- throw new TypeError("The second argument must be a string.");
137
- }
132
+ if (!Array.isArray(json)) throw new TypeError("The first argument must be an array.");
133
+ if (typeof sourceDir !== "string") throw new TypeError("The second argument must be a string.");
138
134
 
135
+ const counts = {};
139
136
  for (const conversation of json) {
140
137
  const sanitizedTitle = sanitizeFileName(conversation.title) || conversation.conversation_id;
141
- const fileName = `${sanitizedTitle}.md`;
138
+ const count = counts[sanitizedTitle] || 0;
139
+ counts[sanitizedTitle] = count + 1;
140
+ const fileName = `${sanitizedTitle}${count ? ` (${count})` : ""}.md`;
142
141
  const filePath = path.join(sourceDir, fileName);
143
142
  const title = `# ${wrapHtmlTagsInBackticks(conversation.title)}\n`;
144
143
  const lines = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatgpt-to-markdown",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Convert ChatGPT exported conversations.json to Markdown",
5
5
  "homepage": "https://github.com/sanand0/chatgpt-to-markdown",
6
6
  "repository": {