From 8bc29b00ab0d2957d0d47f27b6df255650a59d72 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 16 Jul 2023 00:23:47 +1000 Subject: handle refs 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. --- wiki-markup.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'wiki-markup.el') 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 "]*\\)>" limit t) + (let ((start (match-beginning 0)) + (end (if (string-suffix-p "/" (match-string 1)) + (match-end 0) + (when (search-forward "" limit t) + (match-end 0)))) + (next-start (save-excursion + (when (re-search-forward "/]*>" 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 "|") -- cgit v1.2.3