]> gitweb.fluxo.info Git - utils-doc.git/commitdiff
Fix: export-koreader-note: check for empty bookmarks and annotations main
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 9 Mar 2026 20:29:00 +0000 (17:29 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 9 Mar 2026 20:29:00 +0000 (17:29 -0300)
export-koreader-note

index c70a96a68db15a53749c3538f0ff82ea040faf29..35762abd1bc1c154264f44420245066ed4c7f9fb 100755 (executable)
@@ -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