aboutsummaryrefslogtreecommitdiff
path: root/wiki-markup.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-07-16 00:23:47 +1000
committerYuchen Pei <id@ypei.org>2023-07-16 00:23:47 +1000
commit8bc29b00ab0d2957d0d47f27b6df255650a59d72 (patch)
tree195e5f7339a7ed6b6b74c450491a54ddf9310f0a /wiki-markup.el
parentd12b1368079d42a683bfd1098f5e16c300da3612 (diff)
handle refs
<ref> tags are a wikipedia feature. Eventually we would like to render it into numbers like on wikipedia entries. As a first step, let's hide it for now.
Diffstat (limited to 'wiki-markup.el')
-rw-r--r--wiki-markup.el23
1 files changed, 20 insertions, 3 deletions
diff --git a/wiki-markup.el b/wiki-markup.el
index 2993a56..f6d7699 100644
--- a/wiki-markup.el
+++ b/wiki-markup.el
@@ -68,6 +68,7 @@
("^ .*$" . wiki-pre-face)
(wiki-do-emphasis-faces)
;; (wiki-set-template-face)
+ (wiki-do-refs)
(wiki-activate-external-links)
(wiki-activate-internal-links)
(wiki-activate-raw-links)
@@ -101,12 +102,28 @@ This can be overriden with .dir-locals.el."
(length (match-string 2))
6)))
+(defun wiki-do-refs (limit)
+ (while (re-search-forward "<ref\\([^>]*\\)>" limit t)
+ (let ((start (match-beginning 0))
+ (end (if (string-suffix-p "/" (match-string 1))
+ (match-end 0)
+ (when (search-forward "</ref>" limit t)
+ (match-end 0))))
+ (next-start (save-excursion
+ (when (re-search-forward "<ref[^>/]*>" limit t)
+ (match-beginning 0)))))
+ (cond ((not end) (goto-char limit))
+ ((or (not next-start) (>= next-start end))
+ (put-text-property start end 'invisible t)
+ (goto-char end))
+ (t (goto-char next-start))))))
+
(defun wiki-set-template-face (limit)
"Set template faces."
(while (search-forward "{{" limit t)
(save-excursion
(let* ((name-start (point))
- (visible-start name-start)
+ ;; (visible-start name-start)
(start (progn (backward-char 2) (point)))
(end (progn (forward-sexp) (point)))
(visible-end (- end 2))
@@ -115,8 +132,8 @@ This can be overriden with .dir-locals.el."
(if (search-forward "|" visible-end t)
(1- (point))
visible-end))))
- (put-text-property start visible-start 'invisible t)
- (put-text-property visible-end end 'invisible t)
+ ;; (put-text-property start visible-start 'invisible t)
+ ;; (put-text-property visible-end end 'invisible t)
(add-face-text-property name-start name-end 'wiki-special-keyword)
(goto-char name-end)
(while (looking-at "|")