zakame@spunge.org (Zak B. Elep) writes: > I've tried my hand on recreating your hack by redefining some functions: I've updated my code so it will work even if I use the tag: ; I want note IDs preceded by a "note-" so markup validates under xhtml. (defun planner-markup-note () "Replace note with marked-up span." (replace-match (format "#note-%s\n\n** " (match-string 1)))) (defun zakame/emacs-wiki-insert-anchor (anchor) "Insert an anchor, either around the word at point, or within a tag." (skip-chars-forward emacs-wiki-regexp-space) (if (looking-at "<\\([^ />]+\\)>") (let ((tag (match-string 1))) (goto-char (match-end 0)) (insert "") (when emacs-wiki-anchor-on-word (or (and (search-forward (format "" tag) (emacs-wiki-line-end-position) t) (goto-char (match-beginning 0))) (forward-word 1))) (insert "")) (insert "") (when emacs-wiki-anchor-on-word (forward-word 1)) (insert ""))) (defun zakame/emacs-wiki-link-url (wiki-link) "Resolve the given WIKI-LINK into its ultimate URL form." (let ((link (emacs-wiki-wiki-link-target wiki-link))) (save-match-data (cond ((emacs-wiki-wiki-url-p link) (emacs-wiki-escape-url link)) ((or (string-match emacs-wiki-image-regexp link) (string-match emacs-wiki-file-regexp link)) link) ((assoc (emacs-wiki-wiki-base link) (emacs-wiki-file-alist)) (if (string-match "#" link) (concat (emacs-wiki-escape-url (emacs-wiki-published-name (substring link 0 (match-beginning 0)) (emacs-wiki-page-name))) "#note-" (substring link (match-end 0))) (emacs-wiki-escape-url (emacs-wiki-published-name link (emacs-wiki-page-name))))))))) (defalias 'emacs-wiki-insert-anchor 'zakame/emacs-wiki-insert-anchor) (defalias 'emacs-wiki-link-url 'zakame/emacs-wiki-link-url) ; I want anchors to be prepended with "sec-" (defun zakame/emacs-wiki-contents-tag (beg end attrs) (let ((max-depth (let ((depth (cdr (assoc "depth" attrs)))) (or (and depth (string-to-number depth)) 2))) (index 1) base contents l) (save-excursion (save-match-data (catch 'done (while (re-search-forward "^\\(\\*+\\)\\s-+\\(.+\\)" nil t) (setq l (length (match-string 1))) (if (null base) (setq base l) (if (< l base) (throw 'done t))) (when (<= l max-depth) (setq contents (cons (cons l (emacs-wiki-wiki-visible-name (emacs-wiki-match-string-no-properties 2))) contents)) (goto-char (match-beginning 2)) (emacs-wiki-insert-anchor (concat "sec-" (int-to-string index))) (setq index (1+ index))))))) (setq index 1 contents (reverse contents)) (let ((depth 1) (sub-open 0) (p (point))) (insert "
\n") (while contents (insert "
\n") (insert "" (cdar contents) "\n") (setq index (1+ index)) (insert "
\n") (setq depth (caar contents) contents (cdr contents)) (if contents (cond ((< (caar contents) depth) (let ((idx (caar contents))) (while (< idx depth) (insert "
\n\n") (setq sub-open (1- sub-open) idx (1+ idx))))) ;; can't jump more than one ahead ((> (caar contents) depth) (insert "
\n
\n") (setq sub-open (1+ sub-open)))))) (while (> sub-open 0) (insert "
\n
\n") (setq sub-open (1- sub-open))) (insert "\n") (put-text-property p (point) 'read-only t)))) (defalias 'emacs-wiki-contents-tag 'zakame/emacs-wiki-contents-tag) The only gripe with this seems to be in planner-rss publishing: the RSS gives links to notes in "page#number" format, not in "page#note-number". Hmmm... -- ZAK B. ELEP -- 1024D/FA53851D 1486 7957 454D E529 E4F1 F75E 5787 B1FD FA53 851D -- Running Debian GNU+Linux testing/unstable. GnuPG signed mail preferred.