Subject: Re: bug#77299: eww-auto-rename-buffer 'title interaction with eww-readable-urls

From: Jim Porter <[email-masked]>
Date: Wed, 11 Jun 2025 15:17:21 -0700

On 6/11/2025 12:30 PM, Eli Zaretskii wrote:
>> Date: Wed, 11 Jun 2025 10:11:03 -0700
>> Cc: [email-masked]
>> From: Jim Porter <[email-masked]>
>>
>> On 6/9/2025 6:38 AM, Keith Amidon wrote:
>>> A quick update on this: I've been using the version of eww-display-html
>>> quoted below regularly since I last commented on the bug about a month
>>> ago and think it is working fine. If the approach seems acceptable, I'd
>>> be happy to prepare a patch to send to emacs-devel.   --- Keith
>>
>> I think I'd prefer a solution that doesn't require a workaround like
>> this.
> 
> What workaround are you alluding to?

Rendering the original document and immediately re-rendering the 
"readable" form of the document.

>> If we could get a fix that resolves this issue without the
>> workaround, I think that would be best.
> 
> Feel free to suggest a way if you see it.  Both Keith and myself
> looked at the code and concluded that it would be impossible without
> completely rewriting this functionality.  See
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77299#8

I think we could change how we return the readable form of the document. 
Currently, it returns the DOM node of the section we want to render, but 
we could instead return a new document with the <title> node plus the 
DOM node we want to render (ditto for <link> nodes, since we use those 
for things like 'eww-next-url').

Since scoring the readability of the document requires iterating over 
every DOM node, we could just collect the extra nodes we care about 
(like <title>) while iterating. Then it'll be easy to include those 
nodes in the readable form.

Doing it this way should have the benefit that we don't start network 
requests for images that won't be shown in the readable form of the page.