all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Damien Cassou <damien@cassou.me>
To: 56704@debbugs.gnu.org
Cc: Lars Magne Ingebrigtsen <larsi@gnus.org>
Subject: bug#56704: 28.1.90; shr: The DOM is lost in the rendered result
Date: Fri, 22 Jul 2022 17:16:40 +0200	[thread overview]
Message-ID: <87mtd1qisn.fsf@cassou.me> (raw)

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





             reply	other threads:[~2022-07-22 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22 15:16 Damien Cassou [this message]
2022-07-23  5:54 ` bug#56704: 28.1.90; shr: The DOM is lost in the rendered result Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mtd1qisn.fsf@cassou.me \
    --to=damien@cassou.me \
    --cc=56704@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.