diff --git a/README.md b/README.md index 149c5e4..299ac91 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Import Kindle `My Clippings.txt` highlights into Zotero as native annotations, d # Install -1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.17`, or `0.6.16-beta` for preview). +1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.18`, or `0.6.17-beta` for preview). 2. In Zotero: `Tools` → `Plugins` → `gear` → `Install Plugin From File…` → pick the `.xpi` → restart Zotero. 3. `Tools` → `Kanzi…` to open the manager. diff --git a/plugin/bootstrap.js b/plugin/bootstrap.js index 74299f3..69f7c4b 100644 --- a/plugin/bootstrap.js +++ b/plugin/bootstrap.js @@ -548,16 +548,37 @@ var KindleZoteroImporter = { }, mergeComments(existingComment, newComment) { + const stripBracket = (s) => String(s || "").replace(/^\s*\[[^\]]+\]\s*/, "").trim(); const seen = new Set(); const merged = []; for (const comment of [existingComment, newComment]) { for (const part of String(comment || "").split(/\n\s*\n/)) { const cleaned = part.trim(); - if (!cleaned || seen.has(cleaned)) { + if (!cleaned) continue; + // dedup on stripped version too, so "[r] note" and "note" are same + const key = stripBracket(cleaned).toLowerCase() || cleaned.toLowerCase(); + if (seen.has(cleaned) || seen.has(key)) { + // if we have stripped version already, prefer stripped + if (seen.has(key) && cleaned !== stripBracket(cleaned)) { + // replace existing bracket version with stripped if we now have stripped + const idx = merged.findIndex(p => stripBracket(p).toLowerCase() === key); + if (idx >= 0) merged[idx] = stripBracket(cleaned); + seen.add(cleaned); + seen.add(key); + continue; + } continue; } seen.add(cleaned); - merged.push(cleaned); + seen.add(key); + // store stripped version if it had bracket + const stripped = stripBracket(cleaned); + if (stripped !== cleaned) { + merged.push(stripped); + seen.add(stripped); + } else { + merged.push(cleaned); + } } } return merged.join("\n\n"); diff --git a/plugin/manifest.json b/plugin/manifest.json index 6363930..901cbba 100644 --- a/plugin/manifest.json +++ b/plugin/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Kanzi", - "version": "0.6.17", + "version": "0.6.18", "description": "Kindle annotations to Zotero — My Clippings.txt → native annotations.", "homepage_url": "https://github.com/UtkuBilenDemir/kindle-zotero_importer", "author": "Utku Bilen Demir", diff --git a/updates.json b/updates.json index 058b7cd..7fda5f1 100644 --- a/updates.json +++ b/updates.json @@ -2,6 +2,15 @@ "addons": { "kindlezoteroimporter@utkubilen.de": { "updates": [ + { + "version": "0.6.18", + "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.18/kindle-zotero-importer.xpi", + "applications": { + "zotero": { + "strict_min_version": "6.999" + } + } + }, { "version": "0.6.17", "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.17/kindle-zotero-importer.xpi",