aboutsummaryrefslogtreecommitdiff
path: root/wiki-markup.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-07-10 11:23:31 +1000
committerYuchen Pei <id@ypei.org>2023-07-10 11:23:31 +1000
commit49fc5fa02bf06ccc419a8ec26abe3dcdf61a57b0 (patch)
treea184cb3b1cee2bb95f6cce625b88f1f2af7bfbf8 /wiki-markup.el
parent383b7a22e584dd9c5990dcd1b0cdf48f24ffe962 (diff)
Fixing stacking of multiple fonts
There may be italics in header and links, say
Diffstat (limited to 'wiki-markup.el')
-rw-r--r--wiki-markup.el18
1 files changed, 15 insertions, 3 deletions
diff --git a/wiki-markup.el b/wiki-markup.el
index d9cc2c9..63bec0e 100644
--- a/wiki-markup.el
+++ b/wiki-markup.el
@@ -51,6 +51,7 @@
(defvar wiki-font-lock-keywords
(list
+ ;; Headers
(cons "^======.*======\\ *$" 'wiki-level-6)
(cons "^=====.*=====\\ *$" 'wiki-level-5)
(cons "^====.*====\\ *$" 'wiki-level-4)
@@ -58,10 +59,9 @@
(cons "^==.*==\\ *$" 'wiki-level-2)
(cons "^=.*=\\ *$" 'wiki-level-1)
(cons "^----+\\ *$" 'wiki-hr-face)
- (cons "'''''[^ \t\n].*?[^ \t\n]'''''" 'wiki-bold-italic)
- (cons "'''[^ \t\n'].*?[^ \t\n']'''" 'wiki-bold)
- (cons "''[^ \t\n'].*?[^ \t\n']''" 'wiki-italic)
+
(cons "^ .*$" 'wiki-pre-face)
+ '(wiki-do-emphasis-faces)
'(wiki-activate-external-links)
'(wiki-activate-internal-links)
))
@@ -80,6 +80,17 @@
(length (match-string 2))
6)))
+;; Like `org-do-emphasis-faces'
+(defun wiki-do-emphasis-faces (limit)
+ (while (re-search-forward "\\(''+\\)[^ \t\n].*?[^ \t\n']\\(''+\\)" limit t)
+ (let ((start (match-beginning 0))
+ (end (match-end 0)))
+ (pcase (min (length (match-string 1)) (length (match-string 2)))
+ (2 (add-face-text-property start end 'wiki-italic))
+ (3 (add-face-text-property start end 'wiki-bold))
+ (_ (add-face-text-property start end 'wiki-bold-italic))
+ ))))
+
;; Like `org-activate-links'
(defun wiki-activate-links (link-re limit)
(save-excursion
@@ -96,6 +107,7 @@
(make-text-button start end
'action 'wiki-follow-wikilink-action
'button-data `((title . ,title)))
+ (add-face-text-property start end 'org-link)
(put-text-property visible-end end 'invisible t)
(add-text-properties (1- visible-start) visible-start
'(rear-nonsticky (invisible)))