Marking up note headlines with a permalink

(defun sacha/planner-markup-note ()
  "Replace note with marked-up span."
  (let ((id (concat
             emacs-wiki-bare-digits-anchor-prefix
             (match-string 1)))
        (val (match-string 1)))
    (replace-match
     (save-match-data
       (format "#%s\n** %s " id
               (planner-make-link
                (concat (emacs-wiki-page-name)
                        "#" val)
                (concat val ".")))))))

(defalias 'planner-markup-note 'sacha/planner-markup-note)