From dc9ca4e9a6b0bb469b4e156551598f063048282b Mon Sep 17 00:00:00 2001 From: Ashwin Kulasegaram <155372890+kulasegaram@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:39:03 +0000 Subject: [PATCH] NewsDownloader: implement new logic to handle multiple selectors (#12804) Closes #11430. --- .../newsdownloader.koplugin/epubdownloadbackend.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/newsdownloader.koplugin/epubdownloadbackend.lua b/plugins/newsdownloader.koplugin/epubdownloadbackend.lua index 950ab4c7a..a409f5696 100644 --- a/plugins/newsdownloader.koplugin/epubdownloadbackend.lua +++ b/plugins/newsdownloader.koplugin/epubdownloadbackend.lua @@ -46,8 +46,14 @@ local function filter(text, element) "div#newsstorytext", "div.general", } - if element and element ~= "" then - table.insert(selectors, 1, element) + if type(element) == "string" and element ~= "" then + table.insert(selectors, 1, element) -- Insert string at the beginning + elseif type(element) == "table" then + for _, el in ipairs(element) do + if type(el) == "string" and el ~= "" then + table.insert(selectors, 1, el) -- Insert each non-empty element at the beginning + end + end end for _, sel in ipairs(selectors) do local elements = root:select(sel)