summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-10-09 18:54:41 +0300
committerThanos Apollo <[email protected]>2024-10-09 18:54:41 +0300
commite7184dadfd9a8c49e4ce7749a8fd98eec2908c89 (patch)
treeda1eb85ad0ab244c2177fa794f28a0e712f4f731 /gnosis.el
parent68ec07aa6fce9e128dde85bcecfb81e07695d34c (diff)
[fix] cloze-remove-tags: Remove tags & hints as well.
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el8
1 files 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))