From 0d648c5b5cde04307ac4d98e91a44cd850180c13 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 9 Mar 2026 17:29:00 -0300 Subject: [PATCH] Fix: export-koreader-note: check for empty bookmarks and annotations --- export-koreader-note | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/export-koreader-note b/export-koreader-note index c70a96a..35762ab 100755 --- a/export-koreader-note +++ b/export-koreader-note @@ -35,22 +35,32 @@ data = content() bookmarks = data.bookmarks annotations = data.annotations --- Sort -table.sort(bookmarks, compare) -table.sort(annotations, compare) +-- Sort bookmarks +if bookmarks then + table.sort(bookmarks, compare) +end + +-- Sort annotations +if annotations then + table.sort(annotations, compare) +end -- Iterate over bookmarks -for key, item in ipairs(bookmarks) do - print('Page ' .. item.page .. ':') - print('') - print('> ' .. item.notes) - print('') +if bookmarks then + for key, item in ipairs(bookmarks) do + print('Page ' .. item.page .. ':') + print('') + print('> ' .. item.notes) + print('') + end end -- Iterate over annotations -for key, item in ipairs(annotations) do - print('Page ' .. item.page .. ':') - print('') - print('> ' .. item.text) - print('') +if annotations then + for key, item in ipairs(annotations) do + print('Page ' .. item.page .. ':') + print('') + print('> ' .. item.text) + print('') + end end -- 2.39.5