Reading newer epub ebooks with nov.el / shr rendering removes whitespace reddit / emacs ---------------------------------------------------------------------- 525G7bKV · 2022-09-03 12:44 Hello, There is some strange rendering behavior around shr. When I start reading one of the newer epub ebooks from oreilly using nov.el, 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` `
We 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, but with
whitespace 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..."))))`
`* # Das Akronym CRISP-DM steht für `
This html results in a `shr-insert(" steht für ")` as lisp code, but
results as
"Das Akronym CRISP-DMsteht für"
It seems shr always removes the leading whitespace of a string after
it "inserted" it into the buffer?!
----------------------------------------------------------------------
flexibeast · 2022-09-03 13:27
i can reproduce this on my system, using [my epub-create
script](https://github.com/flexibeast/epub-create) i released just the
other day. :-)
What i've found is that adding a space after "We" (and making sure the
para is closed off with a ` A B")
(shr-render-region (point-min) (point-max)))
It only happens when the `a` tag has an `id` attribute.