From 16d0e380ea08ed0f8f872200e2d6db2849fcdb74 Mon Sep 17 00:00:00 2001 From: Mustafa Ali Mutlu Date: Fri, 11 Oct 2019 21:39:13 +0300 Subject: [PATCH] [Plugin] Support for exporting annotations/bookmark renames (#5440) Changes :parseHighlight() to parse renamed bookmarks/highlights see #5408 --- plugins/evernote.koplugin/clip.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/evernote.koplugin/clip.lua b/plugins/evernote.koplugin/clip.lua index 17d5e9e12..59174ae96 100644 --- a/plugins/evernote.koplugin/clip.lua +++ b/plugins/evernote.koplugin/clip.lua @@ -226,7 +226,7 @@ function MyClipping:getImage(image) end end -function MyClipping:parseHighlight(highlights, book) +function MyClipping:parseHighlight(highlights, bookmarks, book) --DEBUG("book", book.file) for page, items in pairs(highlights) do for _, item in ipairs(items) do @@ -235,6 +235,12 @@ function MyClipping:parseHighlight(highlights, book) clipping.sort = "highlight" clipping.time = self:getTime(item.datetime or "") clipping.text = self:getText(item.text) + for _, bookmark in pairs(bookmarks) do + if bookmark.datetime == item.datetime and bookmark.text then + local tmp = string.gsub(bookmark.text, "Page %d+ ", "") + clipping.text = string.gsub(tmp, " @ %d%d%d%d%-%d%d%-%d%d %d%d:%d%d:%d%d", "") + end + end if item.text == "" and item.pos0 and item.pos1 and item.pos0.x and item.pos0.y and item.pos1.x and item.pos1.y then @@ -281,7 +287,7 @@ function MyClipping:parseHistoryFile(clippings, history_file, doc_file) title = title, author = author, } - self:parseHighlight(stored.highlight, clippings[title]) + self:parseHighlight(stored.highlight, stored.bookmarks, clippings.title) end end @@ -312,7 +318,7 @@ function MyClipping:parseCurrentDoc(view) title = title, author = author, } - self:parseHighlight(view.highlight.saved, clippings[title]) + self:parseHighlight(view.highlight.saved, view.ui.bookmark.bookmarks, clippings.title) return clippings end