[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: Tatsuya Kinoshita <tats@xxxxxxxxxxxxxx> さん曰く
Subject: [emacs-w3m:10980] Re: Bug#537327: w3m-el can't render http://www.crummy.com/software/BeautifulSoup/documentation.html
Message-ID: <20090803.204534.59000234.tats%nobody@xxxxxxxxxxxxxxx>
Date: Mon, 03 Aug 2009 20:45:34 +0900 (JST)

>> This URL works in w3m but not in w3m-el:
>> 
>>     http://www.crummy.com/software/BeautifulSoup/documentation.html
>> 
>> To reproduce this:
>> 
>>     emacs -Q -l /etc/emacs/site-start.d/50w3m-el-snapshot.el --eval '(w3m-browse-url "http://www.crummy.com/software/BeautifulSoup/documentation.html")'
>> 
>> The contents of *Messages* is
>> 
>>     ("emacs" "-Q" "-l" "/etc/emacs/site-start.d/50w3m-el-snapshot.el" "--eval" "(w3m-browse-url \"http://www.crummy.com/software/BeautifulSoup/documentation.html\")")
>>     For information about GNU Emacs and the GNU system, type C-h C-a.
>>     error in process sentinel: w3m-fontify-anchors: Wrong type argument: number-or-marker-p, nil
>>     error in process sentinel: Wrong type argument: number-or-marker-p, nil


http://www.crummy.com/software/BeautifulSoup/documentation.html
の該当部分は

> <a name="Using tag names as members"><h3>Using tag names as members</h3></a>
> 
> <p>It's easy to navigate the parse tree by acting as though the name
> of the tag you want is a member of a parser or <code>Tag</code> object. We've
> been doing it throughout these examples. In terms of <a href="#The
> document above">the document above</a>, <code>soup.head</code> gives us the first
> (and, as it happens, only) &lt;HEAD&gt; <code>Tag</code> in the document:

で、href に改行が入っていて、エラーになっているのですね。

w3m, Firefox, Google chrome, safari, IE はエラーにならないけど、
URI として、"#Thedocument%20above" を使っているのでリンクをたど
ることはできませんでした。そもそも、これは NG でしょう。

だけど、エラーになっちゃうのはまずいので、

(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)))))

それともこうやって、積極的に救うか?どっちがよいでしょうか?

## 折角だから下側かしら?

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