standardebooks / tools

The Standard Ebooks toolset for producing our ebook files.
Other
1.43k stars 127 forks source link

Fix to build for current chapter location error affecting AZW3s on Kindle #740

Closed erinendrei closed 3 months ago

erinendrei commented 3 months ago

Resolves part of #605

On the list it was raised that SE AZW3s do not show the correct current chapter location on Kindle. To fix this I proposed appending to the guide a reference element corresponding to the titlepage.

Including a reference element corresponding to any text file seems to fix the Kindle issue. So given that build is already iterating through landmarks in the section edited here, another option would be just to append the bodymatter entry that’s already present in landmarks for each ebook. However, the only appropriate value of the type attribute for the bodymatter landmark's reference element is text, inclusion of which results in SE books opening at the first bodymatter file rather than at the titlepage, the latter being what we want (as far as I understand).

Therefore it seems reasonable to stay with the titlepage solution and not add the first bodymatter file to the guide. Continuing to omit it doesn't seem to affect anything on Kindle. I don't know that it was ever included, given that bodymatter is removed from the type taken from the landmark's epub:type.

faa1c68 removes values from the type attribute allow list that will never occur in a landmark epub:type and therefore cannot occur in the reference node's type as set a few lines above.

3941ca9 ensures that if there is an endnotes file, a reference element corresponding to it will be appended to the guide, for consistency with other backmatter.

acabal commented 3 months ago

Excellent, thanks. Could you just add a comment in there explaining why we do this? Otherwise in the future someone may come across this and try to change it without realizing that we're working around a Kindle issue.

erinendrei commented 3 months ago

Yes, I should have done that. I've pushed some comments (then had to force-push to delete trailing whitespace causing pylint to fail); let me know if you want them reduced/expanded.

acabal commented 3 months ago

Great work, thanks!