[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Google broken
- From: Katsumi Yamaoka <yamaoka@xxxxxxx>
- Date: Fri, 01 Jun 2012 20:10:07 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 11836
- References: <CAJcAo8smRS-FrmZXP5UmYQ9ym+kmsz_aCH1usEsSmVOSRYt0Zg@xxxxxxxxxxxxxx> <b4mobwm9n1g.fsf@xxxxxxx> <CAJcAo8vmSana6SSqEpwWuO8A_KTNTe_JpOMs3qyOZ_Zgtyx8OA@xxxxxxxxxxxxxx> <b4m1um83ket.fsf@xxxxxxx> <CAJcAo8vAAVuHDj5CJPUtkMJKTPNf_VfPtFojh9Pt80_QcK6HYA@xxxxxxxxxxxxxx> <b4mr4u542gf.fsf@xxxxxxx> <CAJcAo8tFSrFpS8TQLFXhC0iGXgbr2Qy4c8DhXrpYLF6fFPwY-A@xxxxxxxxxxxxxx> <b4mvcjbwq1i.fsf@xxxxxxx>
In [emacs-w3m : No.11835] Katsumi Yamaoka wrote:
> Still I have no idea.
I found it out at last. The culprit was the "rowspan" spec.
Try this new filter:
--8<---------------cut here---------------start------------->8---
(setq w3m-use-filter t)
(require 'w3m-filter)
(when (rassoc '(w3m-filter-google) w3m-filter-rules)
(setcdr (rassoc '(w3m-filter-google) w3m-filter-rules)
'(w3m-filter-google-2)))
(defun w3m-filter-google-2 (url)
"Align table columns vertically to shrink the table width."
(let ((case-fold-search t)
last)
(goto-char (point-min))
(while (re-search-forward "<tr[\t\n\r >]" nil t)
(when (w3m-end-of-tag "tr")
(save-restriction
(narrow-to-region (goto-char (match-beginning 0))
(match-end 0))
(setq last nil)
(while (re-search-forward "<td[\t\n\r >]" nil t)
(when (w3m-end-of-tag "td")
(setq last (match-end 0))
(replace-match "<tr>\\&</tr>")))
(when last
(goto-char (+ 4 last))
(delete-char 4))
(goto-char (point-max)))))
;; Remove rowspan and width specs, and <br>s.
(goto-char (point-min))
(while (re-search-forward "<table[\t\n\r >]" nil t)
(when (w3m-end-of-tag "table")
(save-restriction
(narrow-to-region (goto-char (match-beginning 0))
(match-end 0))
(while (re-search-forward "\
\[\t\n\r ]*\\(?:\\(?:rowspan\\|width\\)=\"[^\"]+\"\\|<br>\\)[\t\n\r ]*"
nil t)
;; Preserve a space at the line-break point.
(replace-match " "))
;; Insert a space between ASCII and non-ASCII characters
;; and after a comma.
(goto-char (point-min))
(while (re-search-forward "\
\\([!-~]\\)\\([^ -~]\\)\\|\\([^ -~]\\)\\([!-~]\\)\\|\\(,\\)\\([^ ]\\)"
nil t)
(forward-char -1)
(insert " ")
(forward-char))
(goto-char (point-max)))))))
--8<---------------cut here---------------end--------------->8---