From e7184dadfd9a8c49e4ce7749a8fd98eec2908c89 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 9 Oct 2024 18:54:41 +0300 Subject: [fix] cloze-remove-tags: Remove tags & hints as well. --- gnosis.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gnosis.el b/gnosis.el index 4b36625..420af26 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1173,13 +1173,15 @@ TYPE: Type of gnosis note, must be one of `gnosis-note-types'" (unless (string-match-p cloze sentence) (throw 'not-found nil))) t)) - +;; 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. Works with both single (:), double colons (::), single braces ({}) and -double braces ({{}})." - (let* ((regex "{\\{1,2\\}c[0-9]+:\\{1,2\\}\\([^{}]*?\\)}\\{1,2\\}") +double braces ({{}}). + +Also removes content after a double semicolon (::), which indicate a hint." + (let* ((regex "{\\{1,2\\}c[0-9]+:\\{1,2\\}\\([^:{}]*?\\)\\(::[^{}]*\\)?}\\{1,2\\}") (result (replace-regexp-in-string regex "\\1" string))) result)) -- cgit v1.2.3