John Smith commited on 2023-151 10:40:16
Showing 3 changed files, with 25 additions and 2 deletions.
The "i" option now presents cards (with indices into the deck) containing IMG[path] references to files that don't exist.
| ... | ... |
@@ -15,8 +15,10 @@ function isatty() |
| 15 | 15 |
return succ |
| 16 | 16 |
end |
| 17 | 17 |
|
| 18 |
+IMG_PATTERN = "IMG%[([^%]]+)%]" |
|
| 19 |
+ |
|
| 18 | 20 |
local actions = {}
|
| 19 |
-for _, fname in ipairs({"addcards", "correction", "help", "leeches", "query", "reviewtty", "statistics", "toggle", "vocalreview"}) do
|
|
| 21 |
+for _, fname in ipairs({"addcards", "correction", "help", "imgrefcheck", "leeches", "query", "reviewtty", "statistics", "toggle", "vocalreview"}) do
|
|
| 20 | 22 |
actions[fname:sub(1, 1)] = dofile(SRC_DIR .. fname .. ".lua") |
| 21 | 23 |
end |
| 22 | 24 |
|
| ... | ... |
@@ -0,0 +1,22 @@ |
| 1 |
+local function fn(config, deck, deckfname) |
|
| 2 |
+ local mcl = {}
|
|
| 3 |
+ for i, card in ipairs(deck) do |
|
| 4 |
+ for path in card[1]:spt():gmatch(IMG_PATTERN) do |
|
| 5 |
+ local fh = io.open((deckfname:match(".*/") or "") .. path, "r")
|
|
| 6 |
+ if not fh then |
|
| 7 |
+ table.insert(mcl, i) |
|
| 8 |
+ break |
|
| 9 |
+ end |
|
| 10 |
+ end |
|
| 11 |
+ end |
|
| 12 |
+ if #mcl >= 1 then |
|
| 13 |
+ io.write(string.format("Found %d card%s with bad image references:\n", #mcl, #mcl == 1 and "" or "s"))
|
|
| 14 |
+ else |
|
| 15 |
+ io.write(string.format("No cards with bad image references\n"))
|
|
| 16 |
+ end |
|
| 17 |
+ for _, i in ipairs(mcl) do |
|
| 18 |
+ io.write(string.format("%d %s\n", i, deck[i][1]:spt()))
|
|
| 19 |
+ end |
|
| 20 |
+end |
|
| 21 |
+ |
|
| 22 |
+return { desc = "(i)mage reference check", nd = true, fn = fn }
|
| ... | ... |
@@ -29,7 +29,6 @@ local function imgify(text, basepath, ind, climn, conf) |
| 29 | 29 |
end |
| 30 | 30 |
end |
| 31 | 31 |
-- adapted from https://stackoverflow.com/a/1579673 |
| 32 |
- local IMG_PATTERN = "IMG%[([^%]]+)%]" |
|
| 33 | 32 |
local PATTERN = "(.-)" .. IMG_PATTERN |
| 34 | 33 |
-- Linux/dwm |
| 35 | 34 |
local DISPIMG = function(path, st) |
| 36 | 35 |