Code Monkey home page Code Monkey logo

epub-builder's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

epub-builder's Issues

Library doesn't allow metadata with multiple values

A number of* EPUB's metadata attributes allow repeated elements, for example to define multiple authors:

<dc:creator opf:role="aut">Terry Pratchett</dc:creator>
<dc:creator opf:role="aut">Stephen Briggs</dc:creator>

and multiple genres:

<dc:subject>Fantasy</dc:subject>
<dc:subject>Humour</dc:subject>

(or multiple tags, common in web fiction and fanfiction)

However, this library only allows one instance of each. It's not clear to me what use there is for repeating some of the elements (different languages?) but I checked ebooks I own and found that the following are commonly repeated:

Element Reason
creator Multiple authors
subject Multiple genres/tags
identifier Different opf:schemes (uuid, ISBN, Amazon, ...)

It would be useful for this library to allow this.

*: See § 3.4.3 Metadata and particularly § 3.4.3.3 DCMES Optional Elements

A generated .epub misunderstood by a Kobo eReader

Hi there

I've this https://github.com/rgarrigue/songbook which build an epub through mdbook + mdbook-epub plugin, plugin which use this crate. The resulting epub (you can download it in my repo Releases) is seen a "Unauthorized to read due to Adobe DRM" (unaccurate French to English translation) by my Kobo H2O eReader.

I've reported it there Michael-F-Bryan/mdbook-epub#28, and they adviced me to drop a word here too.

I don't know anything about epub & so on, but feel free to link me some epub to check on my eReader if you want to try possible issues.

Troubles figuring out how to load dummy_image in a real-world scenario

I am trying to add an image to my EPUB by following what's described on README but I cannot seem to pull it off.

let dummy_image = "Not really a PNG image";
(...)
        .add_resource("some_image.png", dummy_image.as_bytes(), "image/png")?

I am miserably failing to figure out the proper way to load the image so that epub_builder can load it into the EPUB.
I use calibre's edit book to check the file and it finds the file but it complains that it's "not a valid image".

I tried loading my image with things like:
let img = ImageReader::open("images/default-vpc-diagram.png").unwrap();

let img = image::open("images/default-vpc-diagram.png").unwrap();

let filename = "images/default-vpc-diagram.png";
let mut img = File::open(&filename).expect("no file found");                                                                                                                                                 
let metadata = fs::metadata(&filename).expect("unable to read metadata");
let mut buffer = vec![0; metadata.len() as usize];
img.read(&mut buffer).expect("buffer overflow");

let img = fs::read(filename).expect("Unable to read file");

I know for a fact my Rust knowledge is limited (very) and I'm failing to see something obvious. Still it would be great to have a more specific case on how to load those images on the README.

Thanks in advance!

epub_builder::Error no longer available for use in next release.

Since 1e3af55, epub_builder::Error is no longer available for using in downstream project. Specifically mdbook-epub is using epub_builder::Error to define a transparent error variant of thiserror. Without that, it would need to introduce eyre as a dependency IIUC and have some changes to upgrade to next release.

Could you consider re-exporting eyre::Report as Error for compatibility? Or give guidance to migrate?

Edit: see also Eyre's doc

We recommend users do not re-export types from this library as part their own public API for libraries with external users.

Cover image metadata

I noticed when generating eBooks with this library, that my eBook reader expect the metadata section for the cover image in content.opf to look like

<meta name="cover" content="cover-image" />

instead of the at the moment generated:

<meta name="cover" content="path/to/image.jpeg" />

(My eBook reader does not show a cover image with the current meta data, but the book is still usable)

this would be easy to fix in line 390 in epub.rs

Note: I don't have access to the epub spec so this 'issue' is based on my empirical observations and might not be an issue with actual epub spec compliance

No compression when use Zip library

It seems that after disabling 'deflate' feature for zip dependency (7c66dfd), all generated epubs are not compressed at all.

If i add direct dependency in my project, with "deflate" feature
zip = { version = "0.5", optional = true, default-features = false, features = ["time", "deflate"] }
zip compression starts working.

Zip file uses wrong slashes on Windows

Zip files should always use forward-slashes in paths (see e.g. this bug report for a citation).

In three different places in epub.rs, a path is created using Path::new("OEBPS").join(...), which uses the default path item separator for the platform. On Windows, this is a backslash.

ZipCommand handles this correctly, but ZipLibrary passes the path on verbatim. The resulting EPUB fails validation at http://validator.idpf.org/ because of files mentioned in the manifest that it can't find (e.g. OEBPS/foo.html) and files that it can see but aren't in the manifest (e.g. OEBPS\foo.html).

A simple solution that I've tested locally is changing https://github.com/lise-henry/epub-builder/blob/master/src/zip_library.rs#L59 to

let file = format!("{}", path.as_ref().display()).replace('\\', "/");

which feels like a hack, but works. I suspect a proper fix would involve also fixing up paths added to the manifest, in case a user adds an EpubContent with a \ in it.

Add async read + write

Hey,
I'm creating multiple ePubs at once and thought about using async rust for file I/O but realized that this crate doesn't support async read and write.

Would it even be feasible sense to add that?

If so, I'd try implementing it myself.

EPUB version

Hello.

  1. I suggest using the function new instead of the function epub_version for set epub version object's EpubBuilder.
  2. I suggest using default EPUB 3.0.1 instead of EPUB 2.0.1.

I can send patches if you don't mind.

Release 0.6

It's been about a year since 0.5. Are there other changes you're planning before 0.6? I currently need the fact that time has been updated so this can be compiled to wasm. Currently I'm pinned to a random githash, but would love to pin to 0.6 and was curious if there was a timeline or other aspects you wanted to finish before cutting.

Thanks for the super useful library!

"This book can't be opened" for example book

I generated the example book by running:

cargo run --example test > test.epub && open test.epub

Trying to open the example book in MacOS Books, I see the following error:

Screen Shot 2020-02-15 at 13 01 56

I can tell from the splash screen and table of contents that the MacOS Books application is able to understand a lot of the structure of the book.

If the README example isn't intended to produce a 100% valid book, what do you think of adding a smaller example that is guaranteed to always produce a valid book as output? I would be happy to take a stab at this.

Bump zip-rs dependency

zip-rs/zip-old#151

As discussed in the issue, zip-rs was adding a comment that caused epub files to have trouble. This issue is now fixed in the git repository but is still not live on cargo.io (https://crates.io/crates/zip).

When the new version is available on cargo.io (Probably going to be v0.5.7), we should upgrade to fix the issue in this repo.

HTML entities (and tags) in chapter titles

At the moment, when generating the inline TOC, chapter titles are stripped of HTML tags using the html2text crate.
This however makes it impossible to use certain titles (e.g. we can't have a chapter named "the <code> tag") and creates an invalid "toc.ncx".
Moreover, using html2text to escape the title can turn valid titles into invalid ones; this happens when the title contains HTML entities (e.g. &amp;), which get converted into the relative character.

The solution could be to use the html_escape crate to escape the title, either using it after html2text or in place of it. If we replace html2text there would be no limitations to the chapter titles, however the behavior would be different than before for titles that contain HTML tags. Using both the crates would limit the possible titles, but still fix the invalid TOC and maintain the current behavior.

Personally I would replace the html2text and use only html_escape, since this would also reduce the dependencies quite a bit.

Once what to do is decided I can create a pull request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.