gaoxiaoliangz / epub-parser Goto Github PK
View Code? Open in Web Editor NEWA powerful yet easy-to-use epub parser
A powerful yet easy-to-use epub parser
A book can have multiple authors. info.authors
should be an array of authors, not string.
example from xml:
<dc:creator opf:role="aut" opf:file-as="Santa & Smith, John">Santa Claus</dc:creator>
<dc:creator opf:role="aut">John Smith</dc:creator>
I tried with several .epub from www.bibebook.com. The IDs are always undefined
the file I'm using for exemple:
http://www.bibebook.com/files/ebook/libre/V2/dumas_alexandre_-_le_docteur_mysterieux_i.epub
I'm using the library in a Vue component:
<v-col>
<v-file-input v-model="file" accept=".epub" label="File input"></v-file-input>
<v-btn v-if="filePresent" @click="handleRead">Lire</v-btn>
</v-col>
...
private handleRead() {
const reader = new FileReader();
reader.onload = evt => {
parseEpub(evt.target!.result as Buffer)
.then((res: Epub) => this.setBook(res))
.catch((err: Error) => window.alert(err.message));
};
reader.readAsArrayBuffer(this.file);
}
private setBook(b: Epub) {
this.book = b;
console.log(this.book);
}
Hello @gaoxiaoliangz,
I have encountered the following error while parsing an ePub:
errorMessage": "Cannot read property 'href' of undefined", "errorType": "TypeError", "stackTrace": [ "TypeError: Cannot read property 'href' of undefined", " at Epub.<anonymous> (/Users/xx/Desktop/workspaces/xxx/node_modules/@gxl/epub-parser/src/parseEpub.ts:185:52)",
I think that the above issue might be because of the toc
attribute not being found in the <spine />
tag. I've tried removing the unused attribute in the .opf file, and replaced it with the expected toc attribute, and I did not have the error anymore.
The ePub 3.2 specifications points out the toc
attribute is optional in the <spine />
. Instead of breaking, shouldn't it advisable to continue the parsing process when the attribute is not found ?
Thanks in advance @gaoxiaoliangz for your reply and keep up the good work ๐
Hi,
some epub files contain images, I would like to extract them? I'm using nodeJS, and I don't know how to import util functions with "require".
Thanks!
heve a problem with importing in ionic-angualr2
One of the packages you depend on is out of date.
warning @gxl/epub-parser > [email protected]: to-markdown has been renamed to Turndown, with a new API. Please update to turndown v4.0.0 or above and see the migration guide for details: https://github.com/domchristie/turndown/wiki/Migrating-from-to-markdown-to-Turndown
โฏ yarn add @gxl/epub-parser
yarn add v1.19.1
[1/4] ๐ Resolving packages...
warning @gxl/epub-parser > [email protected]: to-markdown has been renamed to Turndown, with a new API. Please update to turndown v4.0.0 or above and see the migration guide for details: https://github.com/domchristie/turndown/wiki/Migrating-from-to-markdown-to-Turndown
warning @gxl/epub-parser > to-markdown > jsdom > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐จ Building fresh packages...
success Saved lockfile.
success Saved 11 new dependencies.
info Direct dependencies
โโ @gxl/[email protected]
info All dependencies
โโ @gxl/[email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โโ [email protected]
โจ Done in 13.04s.
Hi,
When I try to use the package with typescript, tsc says that "GeneralObject" and "HtmlNodeObject" unrecognized.
Changing those type to "any" works for me - but there is one problem:
I want to deploy my work on Heroku, and I cannot do so because it downloads the package itself.
I fixed it by changing the package and adding it to my code (not under the node_modules folder)
Just wanted to ask you if you think there is a better solution :)
Thank you!
All images in my epub cannot be found when running toHTMLObjects().
Here's a screenshot. I even tried editing the epub, but it didnt fixed the problem.
Here's the sample epub. Just rename the extension to epub.
sample_book.zip
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.