From e2391c6eedd895de2f43575db596d45d4a7779bd Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 27 Dec 2023 10:03:41 +0200 Subject: Add gnosis-cloze-remove-tags --- gnosis.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gnosis.el b/gnosis.el index 0ef0cef..3ea14da 100644 --- a/gnosis.el +++ b/gnosis.el @@ -248,6 +248,14 @@ choice in the `CHOICES' list. Each note must correspond to one `DECK'. (history-add-new-input nil)) ;; Disable history (completing-read "Answer: " choices))) +(defun gnosis-cloze-remove-tags (string) + "Replace cx-tags in STRING. + +Works both with {} and {{}} to make easier to import anki notes." + (let* ((regex "{\\{1,2\\}c[0-9]+::\\([^}]*\\)}\\{1,2\\}") + (result (replace-regexp-in-string regex "\\1" string))) + result)) + (defun gnosis-cloze-replace-words (string words new) "In STRING replace WORDS with NEW." (cl-assert (listp words)) -- cgit v1.2.3