branch: elpa/gnosis
commit 444a18a24e7b59a4f7b2b3f816517f9062ece3e9
Author: Thanos Apollo <pub...@thanosapollo.org>
Commit: Thanos Apollo <pub...@thanosapollo.org>

    cloze-check: Adjust for quoted input
    
    + This is done to include spaces in quoted inputs.
---
 gnosis.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/gnosis.el b/gnosis.el
index 9f8c7ba546..82f19fffde 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1052,12 +1052,13 @@ answer."
     (gnosis-completing-read "Answer: " choices)))
 
 (defun gnosis-cloze-check (sentence clozes)
-  "Check if CLOZES are found in SENTENCE."
-  (catch 'not-found
-    (dolist (cloze clozes)
-      (unless (string-match-p cloze sentence)
-        (throw 'not-found nil)))
-    t))
+  "Return t if all CLOZES are found in SENTENCE."
+  (cl-every (lambda (cloze)
+              (string-match-p
+               (regexp-quote
+               (string-remove-prefix "\"" (string-remove-suffix "\"" cloze)))
+               sentence))
+            clozes))
 ;; TODO: use a better name to indicate that it also removes hints from STRING.
 (defun gnosis-cloze-remove-tags (string)
   "Replace cloze tags and hints in STRING.

Reply via email to