diff --git a/README.md b/README.md index 86d2778..9dfff97 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.12`, or `0.6.11-beta` for preview). +1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.13`, or `0.6.12-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/manifest.json b/plugin/manifest.json index 94ff9f2..b12d2d6 100644 --- a/plugin/manifest.json +++ b/plugin/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Kanzi", - "version": "0.6.12", + "version": "0.6.13", "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/cli.py b/src/kindle_zotero_importer/cli.py index 434b216..8feda8c 100644 --- a/src/kindle_zotero_importer/cli.py +++ b/src/kindle_zotero_importer/cli.py @@ -419,22 +419,30 @@ def main(argv: list[str] | None = None) -> int: # (so you can recolour a past highlight by adding [r]/[o] etc. to its note or highlight text) if colour_map: import re as _re + # Build map of new notes by title for quick lookup + new_notes_by_title: dict[str, list] = {} + for n in new_clippings_list: + if n.kind == "note" and n.id not in prev_integrated_ids: + # new note (not yet integrated) — check if it has a bracket colour + m = _re.match(r"^\s*\[([^\]]+)\]\s*", n.text or "") + if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}: + new_notes_by_title.setdefault(n.title, []).append(n) for c in new_clippings_list: if c.id not in prev_integrated_ids: continue - # check highlight text and note text for leading [code] - texts = [c.text or ""] - # notes attached to this title may carry the bracket — check all notes for this title - # simplest: if clipping is highlight, its comment (attached note) is in clippings payload; check that too if present - # For incremental we don't yet have attached notes, so check raw clipping text and any note with same title - # For now, check c.text and also any note text that would be attached (we can approximate by checking c.text only) - # Better: check both c.text and the raw note text if kind==highlight and has comment + if c.kind != "highlight": + continue has_bracket = False + # check highlight text itself for t in [c.text or "", getattr(c, "comment", "") or ""]: m = _re.match(r"^\s*\[([^\]]+)\]\s*", t) if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}: has_bracket = True break + # also check if a *new* note for same title would attach to this highlight (by location/page proximity) + # Approximate: any new note with same title is considered for re-queue (conservative, ensures recolours) + if not has_bracket and c.title in new_notes_by_title: + has_bracket = True if has_bracket: to_process_ids.add(c.id) # If colourMap itself changed since last run, re-queue all prev integrated (so Settings change recolours) diff --git a/updates.json b/updates.json index ea8b714..09749d1 100644 --- a/updates.json +++ b/updates.json @@ -2,6 +2,15 @@ "addons": { "kindlezoteroimporter@utkubilen.de": { "updates": [ + { + "version": "0.6.13", + "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.13/kindle-zotero-importer.xpi", + "applications": { + "zotero": { + "strict_min_version": "6.999" + } + } + }, { "version": "0.6.12", "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.12/kindle-zotero-importer.xpi",