From 9622cec49fd70c2f31c671c2735744b6f2273a63 Mon Sep 17 00:00:00 2001 From: Utku Bilen Demir <84389167+UtkuBilenDemir@users.noreply.github.com> Date: Tue, 22 Sep 2026 16:15:50 +0200 Subject: [PATCH] Kanzi 0.6.8: fix [r] on notes colours highlight - src/kindle_zotero_importer/import_plan.py: _annotation_stub now checks comment first for [code] (so [r] on a Kindle note colours its highlight), strips bracket from comment, handles highlight text bracket too - Fixes grey=[r] not applying when note is '[r] this is a red note' with yellow highlight (was all yellow) - Add missing 'color' field (was dropped in previous refactor) - Bump to 0.6.8 for release --- README.md | 2 +- plugin/manifest.json | 2 +- src/kindle_zotero_importer/import_plan.py | 23 ++++++++++++++++++----- updates.json | 9 +++++++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a268f0c..62cb61e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Import Kindle `My Clippings.txt` highlights into Zotero as native annotations; d ## Install (30 seconds) -1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.7`, or `0.6.6-beta` for preview). +1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.8`, or `0.6.7-beta` for preview). 2. In Zotero: `Tools → Plugins → gear → Install Plugin From File…` → pick the `.xpi` → restart Zotero. 3. `Tools → Kanzi…` (or `Kindle Zotero Importer…`) to open the manager. diff --git a/plugin/manifest.json b/plugin/manifest.json index e9493eb..84d6522 100644 --- a/plugin/manifest.json +++ b/plugin/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Kanzi", - "version": "0.6.7", + "version": "0.6.8", "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/src/kindle_zotero_importer/import_plan.py b/src/kindle_zotero_importer/import_plan.py index ac9f13c..6360d26 100644 --- a/src/kindle_zotero_importer/import_plan.py +++ b/src/kindle_zotero_importer/import_plan.py @@ -236,14 +236,27 @@ def _attachment_from_override( def _annotation_stub(clipping: dict[str, Any], colour_map: dict[str, str] | None = None) -> dict[str, Any]: annotation_type = "highlight" if clipping["kind"] == "highlight" else "note" raw_text = clipping["text"] if annotation_type == "highlight" else "" - colour, cleaned = _extract_colour(raw_text, colour_map) - # For highlights, strip the bracket from text; for notes, keep original but still colour from text - text = cleaned if annotation_type == "highlight" else raw_text + raw_comment = clipping.get("comment") or (clipping["text"] if annotation_type == "note" else None) + # Colour from comment first (so [r] on a note colours the highlight), then from highlight text itself + comment_colour, cleaned_comment = _extract_colour(raw_comment or "", colour_map) if raw_comment else ("#ffd400", raw_comment) + text_colour, cleaned_text = _extract_colour(raw_text, colour_map) + if raw_comment and comment_colour != "#ffd400": + colour, comment = comment_colour, cleaned_comment + text = cleaned_text if text_colour != "#ffd400" else raw_text + # also strip bracket from highlight text if it had one + if text_colour != "#ffd400": + text = cleaned_text + elif text_colour != "#ffd400": + colour, text, comment = text_colour, cleaned_text, raw_comment + else: + colour, text, comment = "#ffd400", raw_text, raw_comment + # also clean bracket from comment if it was the source + if comment and comment != raw_comment: + pass # already stripped return { "type": annotation_type, "text": text, - "comment": clipping.get("comment") - or (clipping["text"] if annotation_type == "note" else None), + "comment": comment, "color": colour, "pageLabel": clipping.get("page") or "", "sortIndex": None, diff --git a/updates.json b/updates.json index 888b551..960d41d 100644 --- a/updates.json +++ b/updates.json @@ -2,6 +2,15 @@ "addons": { "kindlezoteroimporter@utkubilen.de": { "updates": [ + { + "version": "0.6.8", + "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.8/kindle-zotero-importer.xpi", + "applications": { + "zotero": { + "strict_min_version": "6.999" + } + } + }, { "version": "0.6.7", "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.7/kindle-zotero-importer.xpi",