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

Re: can't jump to HTML 5 anchors!



From: jidanni@xxxxxxxxxxx said
Subject: [emacs-w3m:11025] can't jump to HTML 5 anchors!
Message-ID: <87d46i6z0o.fsf@xxxxxxxxxxx>
Date: Thu, 27 Aug 2009 05:33:43 +0800

> Help. With newer HTML pages like
> http://radioscanningtw.jidanni.org/index.php?title=台掃:幫助
> jumping to anchors like
>  目錄
>     * 1 範圍
>     * 2 編輯格式
>           o 2.1 呼號...
> just give e.g.,
> .E7.B7.A8.E8.BC.AF.E6.A0.BC.E5.BC.8F is not found

Let's use filter!!

(setq w3m-use-filter t)

(eval-after-load "w3m-filter"
  '(nconc w3m-filter-rules
	  '((".*" w3m-filter-unsupport-tags))))

(defun w3m-filter-unsupport-tags (url)
  (let ((case-fold-search t)
	pos)
    ;; <button
    (w3m-filter-replace-regexp url "<button[\r\t\n ]" "<input ")
    ;; <option disabled
    (w3m-filter-replace-regexp url "<option[\r\t\n ]+disabled>"
			       "<option disabled>[option disabled] ")
    ;; <dfn id="xxxx">
    (goto-char (point-min))
    (while (re-search-forward "<dfn[^>]+id=\\([^>\r\t\n ]+\\)" nil t)
      (replace-match "<a id=\\1" nil nil)
      (unless (looking-at ">")
	(setq pos (point))
	(when (search-forward ">")
	  (delete-region pos (match-beginning 0))))
      (when (search-forward "</dfn>" nil t)
	(replace-match "</a>" nil nil)))
    ;; <span id="xxxx">
    (goto-char (point-min))
    (while (re-search-forward "<span[^>]+id=\\([^>\r\t\n ]+\\)" nil t)
      (replace-match "<a id=\\1" nil nil)
      (unless (looking-at ">")
	(setq pos (point))
	(when (search-forward ">")
	  (delete-region pos (match-beginning 0))))
      (when (search-forward "</span>" nil t)
	(replace-match "</a>" nil nil)))))

-- 
Hideyuki SHIRAI (mailto:shirai@xxxxxxxxxxx)