[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56704: 28.1.90; shr: The DOM is lost in the rendered result
From: |
Damien Cassou |
Subject: |
bug#56704: 28.1.90; shr: The DOM is lost in the rendered result |
Date: |
Fri, 22 Jul 2022 17:16:40 +0200 |
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
- bug#56704: 28.1.90; shr: The DOM is lost in the rendered result,
Damien Cassou <=