diff --git a/apps/readest.koplugin/syncannotations.lua b/apps/readest.koplugin/syncannotations.lua index 50e1dad6..005563ca 100644 --- a/apps/readest.koplugin/syncannotations.lua +++ b/apps/readest.koplugin/syncannotations.lua @@ -300,6 +300,10 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog -- Resolve KOReader page number from xpointer local pageno = ui.document:getPageFromXPointer(xp0) or note.page + -- Resolve chapter title so downstream tools can group by chapter, + -- matching native KOReader highlight creation behavior. + local chapter = ui.toc and ui.toc:getTocTitleByPage(xp0) or nil + if chapter == "" then chapter = nil end if note_type == "bookmark" then if existing_bookmarks[xp0] then goto continue end @@ -309,6 +313,7 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog page = xp0, text = note.text or "", note = note.note or "", + chapter = chapter, pageno = pageno, datetime = datetime_str, datetime_updated = datetime_updated_str, @@ -335,6 +340,7 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog note = note.note or "", drawer = drawer, color = READEST_TO_KO_COLOR[note.color] or "yellow", + chapter = chapter, pageno = pageno, datetime = datetime_str, datetime_updated = datetime_updated_str,