Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epub result not readable on a Sony PRS-T3. #3

Closed
janderholm opened this issue Jan 7, 2018 · 4 comments · Fixed by #8
Closed

Epub result not readable on a Sony PRS-T3. #3

janderholm opened this issue Jan 7, 2018 · 4 comments · Fixed by #8

Comments

@janderholm
Copy link
Contributor

I'm testing to build the The Rustonomicon for use on my Sony PRS-T3. Sadly the resulting .epub in not readable. I ran it through calibre (epub -> epub conversion) and the result is readable and quite good. I've tried a few links and they work. ToC works etc. The pictures do not work for some reason but all in all it's quite useable!

I started looking into why the .epub generated by mdbook-epub does not work right away, and I think I know why.

Running epubcheck on the result gives a lot of errors like this:

ERROR(RSC-005): book/epub/The Rustonomicon.epub/OEBPS/README.html(1,5): Error while parsing file 'elements from namespace "" are not allowed'.
FATAL(RSC-016): book/epub/The Rustonomicon.epub/OEBPS/README.html(2,2): Fatal Error while parsing file 'The markup in the document following the root element must be well-formed.'.
ERROR(RSC-005): book/epub/The Rustonomicon.epub/OEBPS/README.html(-1,-1): Error while parsing file 'The markup in the document following the root element must be well-formed.'.
ERROR(RSC-005): book/epub/The Rustonomicon.epub/OEBPS/meet-safe-and-unsafe.html(1,5): Error while parsing file 'elements from namespace "" are not allowed'.
FATAL(RSC-016): book/epub/The Rustonomicon.epub/OEBPS/meet-safe-and-unsafe.html(2,2): Fatal Error while parsing file 'The markup in the document following the root element must be well-formed.'.

If I compare the result of mdbook-epub with that which has went through calibre I noticed all .html files lack a xml header.

Here's what mdbook-epub generates:

<h1>The Rustonomicon</h1>
<h4>The Dark Arts of Advanced and Unsafe Rust Programming</h4>
<h1>NOTE: This is a draft document that discusses several unstable aspects of Rust, and may contain serious errors or outdated information.</h1>
<blockquote>
<p>Instead of the programs I had hoped for, there came only a shuddering blackness
... and lots more ...

This is what calibre generates:

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Unknown</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <link href="../stylesheet.css" rel="stylesheet" type="text/css"/>
<link href="../page_styles.css" rel="stylesheet" type="text/css"/>
</head>
  <body class="calibre"><h1 class="calibre1">The Rustonomicon</h1>
<h4 class="calibre2">The Dark Arts of Advanced and Unsafe Rust Programming</h4>
<h1 class="calibre1">NOTE: This is a draft document that discusses several unstable aspects of Rust, and may contain serious errors or outdated information.</h1>
<blockquote class="calibre3">
<p class="calibre4">Instead of the programs I had hoped for, there came only a shuddering blackness
... and lots more...
</body></html>

Anyway considering the output is good when ran through calibre, I think this project is quite close to be really useful! I have a Nook Simple Touch and a Sony PRS-T3 and am willing to help test this project with those devices if you want.

@Michael-F-Bryan
Copy link
Owner

It looks like when I'm rendering a chapter's contents I'm converting it directly to HTML and embedding that, whereas I should really be converting to HTML and then inserting into some base template which contains the usual HTML boilerplate.

I haven't added functionality for embedding images yet, so it makes sense that they're not working.

The feature itself is quite easy to implement, it's just a case of adding an extra pass through the book which will collect all the linked images (maybe even fetching them from the internet) and embed them in the book.

@Michael-F-Bryan
Copy link
Owner

For what it's worth, when I was testing this earlier I was able to view the book contents in calibre's embedded viewer. That may also do some pre-processing to "fix" a slightly broken book though...

@bedax
Copy link

bedax commented Jan 7, 2020

EPUBReader also fails to read the file. EPUBCheck 4.1.1 output the following:

Type File Line Position Message
FATAL OEBPS/introduction.html 2 2 Fatal Error while parsing file: The markup in the document following the root element must be well-formed.
FATAL OEBPS/why-rust-and-webassembly.html 2 2 Fatal Error while parsing file: The markup in the document following the root element must be well-formed.
FATAL OEBPS/background-and-concepts.html 2 2 Fatal Error while parsing file: The markup in the document following the root element must be well-formed.

(see the full output here)

The file was generate from https://github.com/rustwasm/book, and the generated book can be found here: https://gofile.io/?c=K91CmB

@bedax
Copy link

bedax commented Jan 8, 2020

The Kobo Forma also fails to open these books.

For anyone looking for a quick fix, open the epub in sigil, which will prompt to automatically fix the ebook, say OK and then save the fixed book.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants