[plugin] Exporter: solved my_clippings OOM (#12107)

Closes #10745.
reviewable/pr12112/r1
Mochitto 3 months ago committed by GitHub
parent 33ae788575
commit 138e26a4fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -11,25 +11,39 @@ local ClippingsExporter = require("base"):new {
} }
local function format(booknotes) local function format(booknotes)
local content = "" local tbl = {}
for ___, entry in ipairs(booknotes) do for ___, entry in ipairs(booknotes) do
for ____, clipping in ipairs(entry) do for ____, clipping in ipairs(entry) do
if booknotes.title and clipping.text then if booknotes.title and clipping.text then
content = content .. booknotes.title .. "\n" table.insert(tbl, booknotes.title)
local header = T(_("- Your highlight on page %1 | Added on %2"), clipping.page, os.date("%A, %B %d, %Y %I:%M:%S %p", clipping.time)) .. "\n\n"
content = content .. header local header = T(_("- Your highlight on page %1 | Added on %2"), clipping.page,
content = content .. clipping.text os.date("%A, %B %d, %Y %I:%M:%S %p", clipping.time))
content = content .. "\n==========\n" table.insert(tbl, header)
table.insert(tbl, "")
table.insert(tbl, clipping.text)
table.insert(tbl, "==========")
if clipping.note then if clipping.note then
content = content .. booknotes.title .. "\n" table.insert(tbl, booknotes.title)
header = T(_("- Your note on page %1 | Added on %2"), clipping.page, os.date("%A, %B %d, %Y %I:%M:%S %p", clipping.time)) .. "\n\n"
content = content .. header .. clipping.note header = T(_("- Your note on page %1 | Added on %2"), clipping.page,
content = content .. "\n==========\n" os.date("%A, %B %d, %Y %I:%M:%S %p", clipping.time))
table.insert(tbl, header)
table.insert(tbl, "")
table.insert(tbl, clipping.note)
table.insert(tbl, "==========")
end end
end end
end end
end end
return content
-- Ensure a newline after the last "=========="
table.insert(tbl, "")
return table.concat(tbl, "\n")
end end
function ClippingsExporter:export(t) function ClippingsExporter:export(t)

Loading…
Cancel
Save