unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56704: 28.1.90; shr: The DOM is lost in the rendered result
@ 2022-07-22 15:16 Damien Cassou
  2022-07-23  5:54 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Damien Cassou @ 2022-07-22 15:16 UTC (permalink / raw)
  To: 56704; +Cc: Lars Magne Ingebrigtsen

Hi,

SHR doesn't link the text being inserted in the buffer and DOM node
being rendered. This means it is not possible to implement some use
cases, e.g.,

- inspect/copy the DOM node rendered at point;

- share/bookmark a link to a particular section of a page (which
  requires knowing the id attribute of the enclosing DOM node).

I fixed this by changing shr-generic from:

(defsubst shr-generic (dom)
  (dolist (sub (dom-children dom))
    (if (stringp sub)
	(shr-insert sub)
      (shr-descend sub))))

to

(defsubst shr-generic (dom)
  (let ((start (point)))
    (dolist (sub (dom-children dom))
      (if (stringp sub)
	  (shr-insert sub)
        (shr-descend sub)))
    (unless (eq start (point-max))
      (put-text-property start (1+ start) 'shr-dom dom))))


This seems to work great.

Is this change desirable? Do you want a patch?

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#56704: 28.1.90; shr: The DOM is lost in the rendered result
  2022-07-22 15:16 bug#56704: 28.1.90; shr: The DOM is lost in the rendered result Damien Cassou
@ 2022-07-23  5:54 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  5:54 UTC (permalink / raw)
  To: Damien Cassou; +Cc: 56704

Damien Cassou <damien@cassou.me> writes:

> SHR doesn't link the text being inserted in the buffer and DOM node
> being rendered.

Yes, shr is already slow enough, so basically all "debugging"-like
things were eschewed.  It'd be nice to have, but if shr is unusably
slow, that's not nice, either.

So we won't be adding something like this, and I'm therefore closing
this bug report.







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-23  5:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 15:16 bug#56704: 28.1.90; shr: The DOM is lost in the rendered result Damien Cassou
2022-07-23  5:54 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).