Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
epub2 is a node.js module to parse EPUB electronic book files.
NB! Only ebooks in UTF-8 are currently supported!.
this module fork from epub
npm install epub2 zipfile
Or, if you want a pure-JS version (useful if used in a Node-Webkit app for example):
npm install epub2
const EPub = require("epub2/node");
import * as EPub from 'epub2/node';
const EPub = require("epub2").EPub;
import EPub from 'epub2';
import { EPub } from 'epub2';
var epub = new EPub(epubfile, imagewebroot, chapterwebroot);
Where
<img>
blocks) is going to be /images/IMG_ID/IMG_FILENAME, IMG_ID
can be used to fetch the image form the ebook with getImage
. Default: /images/
<a>
links) is going to be /chapters/CHAPTER_ID/CHAPTER_FILENAME, CHAPTER_ID
can be used to fetch the image form the ebook with getChapter
. Default: /links/
Before the contents of the ebook can be read, it must be opened (EPub
is an EventEmitter
).
let epub = await EPub.createAsync(epubfile, imagewebroot, chapterwebroot);
EPub.createAsync(epubfile, imagewebroot, chapterwebroot)
.then(function (epub)
{
...
})
.catch(function (err)
{
console.log("ERROR\n-----");
throw err;
})
;
epub.on("end", function(){
// epub is now usable
console.log(epub.metadata.title);
epub.getChapter("chapter_id", function(err, text){});
});
epub.parse();
Property of the epub object that holds several metadata fields about the book.
epub = new EPub(...);
...
epub.metadata;
// raw metadata
epub.metadata[EPub.SYMBOL_RAW_DATA];
Available fields:
flow is a property of the epub object and holds the actual list of chapters (TOC is just an indication and can link to a # url inside a chapter file)
epub = new EPub(...);
...
epub.flow.forEach(function(chapter){
console.log(chapter.id);
});
Chapter id
is needed to load the chapters getChapter
toc is a property of the epub object and indicates a list of titles/urls for the TOC. Actual chapter and it's ID needs to be detected with the href
property
Load chapter text from the ebook.
var epub = new EPub(...);
...
epub.getChapter("chapter1", function(error, text){});
Load raw chapter text from the ebook.
Load image (as a Buffer value) from the ebook.
var epub = new EPub(...);
...
epub.getImage("image1", function(error, img, mimeType){});
Load any file (as a Buffer value) from the ebook.
var epub = new EPub(...);
...
epub.getFile("css1", function(error, data, mimeType){});
change Promise class
EPub.libPromise = Promise;
FAQs
Parse ePub electronic book files with Node.JS
The npm package epub2 receives a total of 35,300 weekly downloads. As such, epub2 popularity was classified as popular.
We found that epub2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.