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

Re: Bug#537327: w3m-el can't render http://www.crummy.com/software/BeautifulSoup/documentation.html



From: Hideyuki SHIRAI (白井秀行) <shirai@xxxxxxxxxxx> 曰く
Subject: [emacs-w3m:10983] Re: Bug#537327: w3m-el can't render http://www.crummy.com/software/BeautifulSoup/documentation.html
Message-ID: <20090804.093931.194975499.shirai.hideyuki@xxxxxxxxxxx>
Date: Tue, 04 Aug 2009 09:39:31 +0900 (JST)

> http://www.crummy.com/software/BeautifulSoup/documentation.html

> だけど、エラーになっちゃうのはまずいので、
> 
> (defun w3m-decode-anchor-string (str)
>   ;; snip
>   (let ((start 0) (buf))
>     (while (string-match "&amp;" str start)
>       (setq buf (cons "&" (cons (substring str start (match-beginning 0)) buf))
> 	    start (match-end 0)))
>     (setq str
> 	  (apply (function concat)
> 		 (nreverse (cons (substring str start) buf))))
>     (setq start 0)
>     (setq buf nil)
>     (while (string-match "[\t\r\f\n]+" str start)
>       (setq buf (cons (substring str start (match-beginning 0)) buf)
> 	    start (match-end 0)))
>     (apply (function concat)
> 	   (nreverse (cons (substring str start) buf)))))
> 
> として、他のブラウザと一緒にしたぐらいでよいか、
> 
> (defun w3m-decode-anchor-string (str)
>   ;; snip
>   (let ((start 0) (buf))
>     (while (string-match "&amp;" str start)
>       (setq buf (cons "&" (cons (substring str start (match-beginning 0)) buf))
> 	    start (match-end 0)))
>     (setq str
> 	  (apply (function concat)
> 		 (nreverse (cons (substring str start) buf))))
>     (setq start 0)
>     (setq buf nil)
>     (while (string-match "[\t\r\f\n]+" str start)
>       (setq buf (cons " " (cons (substring str start (match-beginning 0)) buf))
> 	    start (match-end 0)))
>     (apply (function concat)
> 	   (nreverse (cons (substring str start) buf)))))
> 
> それともこうやって、積極的に救うか?どっちがよいでしょうか?

二回ループ回すのもなんだからこうかな?

(defun w3m-decode-anchor-string (str)
  ;; snip
  (let ((start 0) (buf))
    (while (string-match "\\(&amp;\\)\\|\\([\t\r\f\n]+\\)" str start)
      (setq buf (cons (if (match-beginning 1) "&" " ")
		      (cons (substring str start (match-beginning 0)) buf))
	    start (match-end 0)))
    (apply (function concat)
	   (nreverse (cons (substring str start) buf)))))

-- 
白井秀行 (mailto:shirai@xxxxxxxxxxx)