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 935bc049ce
commit 9622cec49f
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)
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.

View file

@ -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",

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]:
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,

View file

@ -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",