Exporter clip: annotations

reviewable/pr11563/r9
hius07 2 months ago committed by GitHub
parent e9603b4be1
commit 154fdc90a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -235,6 +235,23 @@ function MyClipping:getImage(image)
end end
end end
function MyClipping:parseAnnotations(annotations, book)
for _, item in ipairs(annotations) do
if item.drawer then
local clipping = {
sort = "highlight",
page = item.pageno,
time = self:getTime(item.datetime),
text = self:getText(item.text),
note = self:getText(item.note),
chapter = item.chapter,
drawer = item.drawer,
}
table.insert(book, { clipping })
end
end
end
function MyClipping:parseHighlight(highlights, bookmarks, book) function MyClipping:parseHighlight(highlights, bookmarks, book)
--DEBUG("book", book.file) --DEBUG("book", book.file)
@ -249,13 +266,14 @@ function MyClipping:parseHighlight(highlights, bookmarks, book)
local orphan_highlights = {} local orphan_highlights = {}
for page, items in pairs(highlights) do for page, items in pairs(highlights) do
for _, item in ipairs(items) do for _, item in ipairs(items) do
local clipping = {} local clipping = {
clipping.page = page sort = "highlight",
clipping.sort = "highlight" page = page,
clipping.time = self:getTime(item.datetime or "") time = self:getTime(item.datetime or ""),
clipping.text = self:getText(item.text) text = self:getText(item.text),
clipping.chapter = item.chapter chapter = item.chapter,
clipping.drawer = item.drawer drawer = item.drawer,
}
local bookmark_found = false local bookmark_found = false
for _, bookmark in pairs(bookmarks) do for _, bookmark in pairs(bookmarks) do
if bookmark.datetime == item.datetime then if bookmark.datetime == item.datetime then
@ -316,9 +334,13 @@ end
function MyClipping:getClippingsFromBook(clippings, doc_path) function MyClipping:getClippingsFromBook(clippings, doc_path)
local doc_settings = DocSettings:open(doc_path) local doc_settings = DocSettings:open(doc_path)
local highlights = doc_settings:readSetting("highlight") local highlights, bookmarks
if not highlights then return end local annotations = doc_settings:readSetting("annotations")
local bookmarks = doc_settings:readSetting("bookmarks") if annotations == nil then
highlights = doc_settings:readSetting("highlight")
if highlights == nil then return end
bookmarks = doc_settings:readSetting("bookmarks")
end
local props = doc_settings:readSetting("doc_props") local props = doc_settings:readSetting("doc_props")
props = FileManagerBookInfo.extendProps(props, doc_path) props = FileManagerBookInfo.extendProps(props, doc_path)
local title, author = self:getTitleAuthor(doc_path, props) local title, author = self:getTitleAuthor(doc_path, props)
@ -326,8 +348,13 @@ function MyClipping:getClippingsFromBook(clippings, doc_path)
file = doc_path, file = doc_path,
title = title, title = title,
author = author, author = author,
number_of_pages = doc_settings:readSetting("doc_pages"),
} }
self:parseHighlight(highlights, bookmarks, clippings[title]) if annotations then
self:parseAnnotations(annotations, clippings[title])
else
self:parseHighlight(highlights, bookmarks, clippings[title])
end
end end
function MyClipping:parseHistory() function MyClipping:parseHistory()
@ -361,7 +388,7 @@ function MyClipping:parseCurrentDoc(view)
output_filename = util.getSafeFilename(title), output_filename = util.getSafeFilename(title),
number_of_pages = view.document.info.number_of_pages, number_of_pages = view.document.info.number_of_pages,
} }
self:parseHighlight(view.highlight.saved, view.ui.bookmark.bookmarks, clippings[title]) self:parseAnnotations(view.ui.annotation.annotations, clippings[title])
return clippings return clippings
end end

Loading…
Cancel
Save