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

Re: improper indentation in w3m upon <a>



>>>>> In [emacs-w3m : No.10486] jidanni@xxxxxxxxxxx wrote:

> Actually w3m is differentiating between name/href:

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd";>
> <html>
> <head>
>  <title>w3m test</title>
> </head>
> <body>
>  <ul>
>   <li><a name="z" id="z"></a><a href="z">OK</a></li>
>   <li><a href="z"></a><a href="z">Bad in w3m</a></li>
>   <li><a href="z">OK</a></li>
>  </ul>
> </body>
> </html>

Hm, I don't know why, but I confirmed w3m renders at least
    <a href="z"></a>
as: <a href="z"> </a>

> Actually I use that trick often, like in http://jidanni.org/makefile
> target:%_en.html

I see.  Could you test this hook with such html contents?

--8<---------------cut here---------------start------------->8---
(defun my-w3m-remove-hidden-anchors ()
  "Remove hidden anchors like \"<a href=url></a>\" in the current buffer."
  (goto-char (point-min))
  (let ((case-fold-search t))
    (while (re-search-forward "<a[\t\n ]+[^>]+>[\t\n ]*</a>" nil t)
      (delete-region (match-beginning 0) (match-end 0)))))

(add-hook 'w3m-fontify-before-hook 'my-w3m-remove-hidden-anchors)
--8<---------------cut here---------------end--------------->8---

If it is ok, I'll embed the identical thing into emacs-w3m.

Regards,