diff options
author | Thanos Apollo <[email protected]> | 2024-06-28 04:21:38 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-06-28 04:21:38 +0300 |
commit | 0749549451eddf3ccc9a758d9a55a9c67a5d5ea5 (patch) | |
tree | 4659ab4c3b2272bacf7feb602188101164ca933e /gnosis.el | |
parent | 11cc9e9efe808a73e740d96235f875721f634429 (diff) |
[Feature] Add gnosis-apply-syntax-overlay
Adds org-mode like syntax highlighting
Diffstat (limited to 'gnosis.el')
-rw-r--r-- | gnosis.el | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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." |