unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Reading newer oreilly books / shr rendering removes whitespace
@ 2022-08-15 17:21 Marcus Kammer
  0 siblings, 0 replies; only message in thread
From: Marcus Kammer @ 2022-08-15 17:21 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 6319 bytes --]

Hello,

There is some strange rendering behavior around shr.

When I start reading one of the newer epub ebooks from oreilly, in some
sentences the whitespace between two words is missing.

For instance:

#+begin_example
Wecan’t stress enough the importance of experimentation as you learn new concepts here and throughout the book.
#+end_example

Here, the whitespace is missing between `We` and `can't`.

So I did checked the xhtml source of the epub:

#+begin_src html
<p>We<a data-type="indexterm" data-primary="code examples" data-secondary="downloading" id="idm45654236145288"/><a data-type="indexterm" data-primary="online resources" data-secondary="code examples" id="idm45654236144280"/><a data-type="indexterm" data-primary="GitHub, code examples from" id="idm45654236143336"/> can’t stress enough the importance of experimentation as you learn new concepts here and throughout the book.
#+end_src

As you can see, there is an anchor tag between the words.

So I started `debug-on-entry` on the function `libxml-parse-html-region` to see
what happened with the dom.

This is my debug log:

#+begin_example
Debugger entered--entering a function:
* undo-auto--undoable-change()
* shr-insert(" can’t stress enough the importance of experimenta...")
* shrface-tag-p((p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))
* shr-descend((p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))
* shr-tag-body((body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta...")))
* shr-descend((body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta...")))
* shr-tag-html((html nil (body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))))
* shr-descend((html nil (body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))))
* #<subr shr-insert-document>((html nil (body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))))
* apply(#<subr shr-insert-document> (html nil (body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))))
* shr-insert-document((html nil (body nil (p nil "We" (a ((data-type . "indexterm") (data-primary . "code examples") (data-secondary . "downloading") (id . "idm45654236145288"))) (a ((data-type . "indexterm") (data-primary . "online resources") (data-secondary . "code examples") (id . "idm45654236144280"))) (a ((data-type . "indexterm") (data-primary . "GitHub, code examples from") (id . "idm45654236143336"))) " can’t stress enough the importance of experimenta..."))))
  shr-render-buffer(#<buffer test.xhtml>)
  funcall-interactively(shr-render-buffer #<buffer test.xhtml>)
  call-interactively(shr-render-buffer record nil)
  command-execute(shr-render-buffer record)
  execute-extended-command(nil "shr-render-buffer" "shr-re")
  funcall-interactively(execute-extended-command nil "shr-render-buffer" "shr-re")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
#+end_example

The whitespace is inserted correctly. But after calling
`undo-auto--undoable-change()` I did see that the whitespace was removed in the
*html* buffer.

What is happening here?

Thank you!

--
Cheers Marcus (Nuremberg . Germany)
GnuPG Key: https://meta.sr.ht/~marcuskammer.pgp
Fingerprint: 86DB 0F30 F9F1 661A 54E2 1664 C374 817B E285 268F

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 524 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-15 17:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 17:21 Reading newer oreilly books / shr rendering removes whitespace Marcus Kammer

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).