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

Re: HTML 5 search boxes gone



From: jidanni@xxxxxxxxxxx said
Subject: [emacs-w3m:11057] HTML 5 search boxes gone
Message-ID: <87r5ue88j3.fsf@xxxxxxxxxxx>
Date: Fri, 11 Sep 2009 11:28:16 +0800

> How will one do searches on Wikipedia soon when they upgrade their site
> to HTML 5?
> 
> You might say "we'll just add yet another workaround filter!".

I thought that I said just now, "Use the filter". :-)

> But sooner or later one will have to face the facts and update the
> underlying w3m program, so it can deal with
> <input id="searchInput" title="Search ABJ" accesskey="f" type="search" name="search" />

Please let me consult by developers about this matter. 

.........................

By the way, I update my filter & hook ;-p

(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
    (goto-char (point-min))
    (while (re-search-forward "<option\\([^>]+\\)disabled[^>]*>" nil t)
      (goto-char (match-end 0))
      (insert "[disabled] "))
    ;; <input type="search" name="search" />
    (goto-char (point-min))
    (while (and (re-search-forward "<input " nil t)
		(re-search-forward "[^>]*type=\"\\(search\\)\"" nil t))
      (goto-char (match-beginning 1))
      (delete-region (match-beginning 1) (match-end 1))
      (insert "text"))
    ;; <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 ">" nil t)
	  (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 ">" nil t)
	  (delete-region pos (match-beginning 0))))
      (when (search-forward "</span>" nil t)
	(replace-match "</a>" nil nil)))))

(add-hook 'w3m-form-input-select-mode-hook 'my-w3m-form-select)

(defun my-w3m-form-select ()
  (let ((buffer-read-only nil))
    (save-excursion
      (goto-char (point-min))
      (while (not (eobp))
	(if (looking-at "^\\[disabled\\] ")
	    (progn
	      (put-text-property (match-end 0)
				 (line-end-position)
				 'face 'w3m-strike-through)
	      (add-text-properties (max (point-min) (1- (line-beginning-position)))
				 (min (point-max) (1+ (line-end-position)))
				 '(intangible t point-entered
					      (lambda (x y) (beginning-of-line)))))
	  (put-text-property (line-beginning-position)
			     (line-end-position)
			     'face 'w3m-anchor))
	(forward-line 1))
      (setq goal-column 0)
      (set-buffer-modified-p nil))))

-- 
Hideyuki SHIRAI (mailto:shirai@xxxxxxxxxxx)
と言っても、私は只今絶賛納期前のパニック中。