emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] xhtml-valid note id attributes (was Re: Planner-pub


From: Zak B. Elep
Subject: [emacs-wiki-discuss] xhtml-valid note id attributes (was Re: Planner-publishing markup)
Date: Tue, 26 Jul 2005 11:20:24 +0800
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Sacha Chua <address@hidden> writes:

> I can put the note1, note2 hack back in, but people will need to
> republish their pages for the anchors to work again. (Or we can
> cheerfully ignore the rules... Hmm...)

I've tried my hand on recreating your hack by redefining some functions:

; I want note IDs preceded by a "note-" so markup validates under xhtml.
(defun zakame/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 "<a id=\"note-" anchor "\">")
        (when emacs-wiki-anchor-on-word
          (or (and (search-forward (format "</%s>" tag)
                                   (emacs-wiki-line-end-position) t)
                   (goto-char (match-beginning 0)))
              (forward-word 1)))
        (insert "</a>"))
    (insert "<a id=\"note-" anchor "\">")
    (when emacs-wiki-anchor-on-word
      (forward-word 1))
    (insert "</a>")))

(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 'planner-markup-note 'zakame/planner-markup-note)
(defalias 'emacs-wiki-insert-anchor 'zakame/emacs-wiki-insert-anchor)
(defalias 'emacs-wiki-link-url 'zakame/emacs-wiki-link-url)

The code above seems to work, except that when I invoke M-x remember or
planner-replan-note (bothe seem to invoke planner-visit-link) I get

Symbol's function definition is void: planner-visit-link

doing a (defalias 'planner-visit-link 'emacs-wiki-visit-link) seems to
fix it, but I don't know if this is the right hack.

Any ideas to improve on this?

-- 
ZAK B. ELEP     <address@hidden>        --      <http://zakame.spunge.org>
1024D/FA53851D          1486 7957 454D E529 E4F1  F75E 5787 B1FD FA53 851D
--  Running Debian GNU+Linux testing/unstable. GnuPG signed mail preferred.

Attachment: pgpQ9Zg9P6Nf6.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]