Remove braces in Prompt:text() for bmc
John Smith

John Smith commited on 2023-177 12:43:56
Showing 4 changed files, with 4 additions and 6 deletions.

... ...
@@ -79,7 +79,7 @@ end
79 79
     question-text, question-lang, answer-text, answer-lang
80 80
 ]]
81 81
 defaultprspeak = function(pr)
82
-    return {(pr:text():gsub("%{([^{}]+)%}", "%1"):gsub("%%A", "WHAT"))}, {false}, {"ANSWER: " .. pr:ans()}, {false}
82
+    return {(pr:text():gsub("%%A", "WHAT"))}, {false}, {"ANSWER: " .. pr:ans()}, {false}
83 83
 end
84 84
 prspeak = defaultprspeak
85 85
 do
... ...
@@ -37,7 +37,7 @@ function Prompt:text()
37 37
     end
38 38
     if self.card.ct == "bmc" then
39 39
         local _, eoa = self.card.note:find("{[^}]+}", self.ind)
40
-        return self.card.note:sub(1, self.ind - 1) .. "%A" .. self.card.note:sub(eoa + 1)
40
+        return (self.card.note:sub(1, self.ind - 1) .. "%A" .. self.card.note:sub(eoa + 1)):gsub("{([^}]+)}", "%1")
41 41
     else
42 42
         return "error: unrecognised card type " .. self.card.ct
43 43
     end
... ...
@@ -125,8 +125,7 @@ local function fn(config, deck, deckfname)
125 125
             break
126 126
         end
127 127
         local pr = deck[ip[1]].pr[ip[2]]
128
-        -- remove braces for display
129
-        local pst = pr:text():gsub("%{([^{}]+)%}", "%1")
128
+        local pst = pr:text()
130 129
         local st = os.time()
131 130
         imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "", ind, climn, config, true)
132 131
         io.write("\n")
... ...
@@ -45,8 +45,7 @@ local function fn(config, deck, deckfname)
45 45
             break
46 46
         end
47 47
         local pr = deck[ip[1]].pr[ip[2]]
48
-        -- remove braces for display
49
-        local pst = pr:text():gsub("%{([^{}]+)%}", "%1")
48
+        local pst = pr:text()
50 49
         local st = os.time()
51 50
         io.write(pst .. "\n" .. ind .. "/" .. climn .. "\n")
52 51
         local qt, ql, at, al = prspeak(pr)
53 52