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
This commit is contained in:
Utku Bilen Demir 2026-09-22 16:15:50 +02:00
parent 98539dadbd
commit 48359919ec
4 changed files with 29 additions and 7 deletions

View file

@ -10,7 +10,7 @@ Import Kindle `My Clippings.txt` highlights into Zotero as native annotations; d
## Install (30 seconds) ## 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. 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. 3. `Tools → Kanzi…` (or `Kindle Zotero Importer…`) to open the manager.

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Kanzi", "name": "Kanzi",
"version": "0.6.7", "version": "0.6.8",
"description": "Kindle annotations to Zotero — My Clippings.txt → native annotations.", "description": "Kindle annotations to Zotero — My Clippings.txt → native annotations.",
"homepage_url": "https://github.com/UtkuBilenDemir/kindle-zotero_importer", "homepage_url": "https://github.com/UtkuBilenDemir/kindle-zotero_importer",
"author": "Utku Bilen Demir", "author": "Utku Bilen Demir",

View file

@ -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]: 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" annotation_type = "highlight" if clipping["kind"] == "highlight" else "note"
raw_text = clipping["text"] if annotation_type == "highlight" else "" raw_text = clipping["text"] if annotation_type == "highlight" else ""
colour, cleaned = _extract_colour(raw_text, colour_map) raw_comment = clipping.get("comment") or (clipping["text"] if annotation_type == "note" else None)
# For highlights, strip the bracket from text; for notes, keep original but still colour from text # Colour from comment first (so [r] on a note colours the highlight), then from highlight text itself
text = cleaned if annotation_type == "highlight" else raw_text 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 { return {
"type": annotation_type, "type": annotation_type,
"text": text, "text": text,
"comment": clipping.get("comment") "comment": comment,
or (clipping["text"] if annotation_type == "note" else None),
"color": colour, "color": colour,
"pageLabel": clipping.get("page") or "", "pageLabel": clipping.get("page") or "",
"sortIndex": None, "sortIndex": None,

View file

@ -2,6 +2,15 @@
"addons": { "addons": {
"kindlezoteroimporter@utkubilen.de": { "kindlezoteroimporter@utkubilen.de": {
"updates": [ "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", "version": "0.6.7",
"update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.7/kindle-zotero-importer.xpi", "update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.7/kindle-zotero-importer.xpi",