Filter "fancy" cards from review list
John Smith

John Smith commited on 2022-103 17:04:27
Showing 2 changed files, with 12 additions and 3 deletions.


This change should be temporary.
When reviewing, cards that use non-ASCII Unicode or image display
will not be included in the review queue.
... ...
@@ -174,7 +174,10 @@ elseif action == "r" then
174 174
     local deck = loader.load(deckfname)
175 175
     if deck then
176 176
         -- collect list of index-pairs for prompts to be reviewed this session
177
-        local ctrt = review.list(deck)
177
+        local ctrt = review.list(deck, function(pr)
178
+            -- exclude prompts that use images or Unicode
179
+            return (not pr.text:find("IMG%[")) and (not pr.text:find("[\u{81}-\u{FFFFF}]"))
180
+        end)
178 181
         io.write(string.format(
179 182
             "%d prompts are ready for review.\nHow many to review in this session? ", #ctrt
180 183
         ))
... ...
@@ -57,16 +57,22 @@ local function shuffle(t)
57 57
     return ret
58 58
 end
59 59
 
60
+local function alwaystrue(x)
61
+    return true
62
+end
63
+
60 64
 --[[
61 65
     returns a table of pairs of integers to index the deck
62 66
     to get prompts to be reviewed now;
63 67
     prompts are shuffled in order
68
+    if a filter function is provided, filters the list accordingly,
69
+    calling the filter function on each `Prompt`
64 70
 ]]
65
-local function toreviewlist(deck)
71
+local function toreviewlist(deck, filter)
66 72
     local ctrt = {}
67 73
     for i, cg in ipairs(deck) do
68 74
         for j, pr in ipairs(cg) do
69
-            if should(pr) then
75
+            if should(pr) and (filter or alwaystrue)(pr) then
70 76
                 table.insert(ctrt, { i, j })
71 77
             end
72 78
         end
73 79