From 0749549451eddf3ccc9a758d9a55a9c67a5d5ea5 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 28 Jun 2024 04:21:38 +0300 Subject: [Feature] Add gnosis-apply-syntax-overlay Adds org-mode like syntax highlighting --- gnosis.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gnosis.el b/gnosis.el index 89150fc..e6ab7fa 100644 --- a/gnosis.el +++ b/gnosis.el @@ -349,6 +349,23 @@ This will not be applied to sentences that start with double space." (gnosis-center-current-line) (forward-line 1)))) +(defun gnosis-apply-syntax-overlay () + "Apply custom font overlays for syntax highlighting, and remove delimiters." + (let ((syntax-highlights '(("\\*\\([^*[:space:]][^*]*[^*[:space:]]\\)\\*" . bold) + ("/\\([^/[:space:]][^/]*[^/[:space:]]\\)/" . italic) + ("=\\([^=[:space:]][^=]*[^=[:space:]]\\)=" . font-lock-constant-face) + ("~\\([^~[:space:]][^~]*[^~[:space:]]\\)~" . font-lock-keyword-face)))) + (save-excursion + (cl-loop for (regex . face) in syntax-highlights + do (progn + (goto-char (point-min)) + (while (re-search-forward regex nil t) + (let ((start (match-beginning 1)) + (end (match-end 1))) + (overlay-put (make-overlay start end) 'face face) + (delete-region end (match-end 0)) + (delete-region (match-beginning 0) start)))))))) + (defun gnosis-display-mcq-options (id) "Display answer options for mcq note ID." -- cgit v1.2.3