From 50be722192a13bb757d27295e8f107a41ad7229a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 16 Jul 2024 14:04:48 +0300 Subject: cloze: Add gnosis-cloze-mark-answers * Mark answers in cloze review using FACE. --- gnosis.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gnosis.el b/gnosis.el index f7bb550..7d66ab5 100644 --- a/gnosis.el +++ b/gnosis.el @@ -477,6 +477,18 @@ Refer to =gnosis-db-schema-extras' for informations on images stored." (replace-match (propertize (format "[%s]" (nth count hints)) 'face 'gnosis-face-cloze))) (setq count (1+ count))) (buffer-string)))) + +(defun gnosis-cloze-mark-answers (str answers face) + "Mark ANSWERS in STR with FACE." + (cl-assert (listp answers) nil "Answers to mark must be a list.") + (with-temp-buffer + (insert str) + (goto-char (point-min)) + (dolist (answer answers) + (when (search-forward answer nil t) + (replace-match (propertize answer 'face face) nil t))) + (buffer-string))) + (defun gnosis-display-basic-answer (answer success user-input) "Display ANSWER. -- cgit v1.2.3