New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

epub-parse

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

epub-parse

A powerful yet easy-to-use epub parser

latest
Source
npmnpm
Version
1.0.9
Version published
Weekly downloads
12
-14.29%
Maintainers
1
Weekly downloads
 
Created
Source

📖 epub-parser

A powerful yet easy-to-use epub parser

npm version build state

The package exports a simple parser function which use epub file as input and output JavaScript object.

As it is written in TypeScript, types are already included in the package.

Inspired by @gxl/epub-parser but without dependency to fs, which allows it to use this lib with react-native.

Install

npm install davidka/epub-parser --save

or if you prefer yarn

yarn add davidka/epub-parser

Usage

import parser from 'davidka/epub-parser'
// if you use `require` don't forget to add `.default`
// const parser = require('simple-epub-parser').default

console.log('epub content:', parser(binaryData))

parser(target: buffer, options?: object): EpubObject

target

type: buffer

EpubObject

The output is an object which contains structure, sections, info along with some other properties that deals with the epub file. They start with _. I don't recommend using these properties, since they are subscribed to change. They are where they are simply because JavaScript don't have native private member variable support, and sometimes they are helpful for debugging.

structure is the parsed toc of epub file, they contain information about how the book is constructed.

sections is an array of chapters or sections under chapters, they are referred in structure. Each section object contains the raw html string and a few handy methods to help you with you needs. toMarkdown convert the current section to markdown object. toHtmlObjects converts to html object. And a note about src and href, the src and href in raw html stay untouched, but the toHtmlObjects method resolves src to base64 string, and alters href so that they make sense in the parsed epub. And the parsed href is something like #{sectionId},{hash}.

One more thing

It provides some util functions as well.

They can be used via

import { parseLink, parseHTML, parseNestedObject, flattenArray } from 'davidka/epub-parser'
  • parseLink
  • parseHTML
  • parseNestedObject

How to contribute

  • Raise an issue in the issue section.
  • PRs are the best.

❤️

Keywords

epub-parser

FAQs

Package last updated on 23 Feb 2018

Did you know?

Socket

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.

Install

Related posts