jepub

2.1.4 • Public • Published

jEpub

npm version FOSSA Status

Simple EPUB builder library, works in modern browsers.

Demo

  1. /demo
  2. jsfiddle.net/rhov44gg

Installation

npm install --save jepub

You can also use it via a CDN:

<script src="https://unpkg.com/jepub/dist/jepub.min.js"></script>

or:

<script src="https://cdn.jsdelivr.net/npm/jepub/dist/jepub.min.js"></script>

Dependencies

jEpub requires JSZip and EJS. Make sure these libraries are loaded before starting your code.

<script src="jszip.js"></script>
<script src="ejs.js"></script>
<script src="jepub.js"></script>
<script>
    const jepub = new jEpub()
    // jepub.init({
    // do something
</script> 

Usage

const jepub = new jEpub()
jepub.init({
    i18n: 'en', // Internationalization
    title: 'Book title',
    author: 'Book author',
    publisher: 'Book publisher',
    description: '<b>Book</b> description', // optional
    tags: [ 'epub', 'tag' ] // optional
})
  • i18n only include the language codes defined in i18n.json
  • description: HTML string.
  • tags: Array.

Set published date

jepub.date(dateobject)
  • date: Date Object.

Set identifier

jepub.uuid(idstring | number)
  • id: Unique id.

Add cover

jepub.cover(dataobject)
  • data: A Blob or an ArrayBuffer object from XMLHttpRequest.

Add notes

jepub.notes(contentstring)
  • content: HTML string.

Add chapter *

jepub.add(titlestring, contentstring | array)
  • title: Plain text.
  • content:
    • string: HTML string.
    • array: Plain text for each item.

Add image

jepub.image(dataobject, IMG_IDstring)
  • data: A Blob or an ArrayBuffer object from XMLHttpRequest.
  • IMG_ID: Unique id.

Place <%= image[IMG_ID] %> inside the chapter's content (HTML string only), where you want to display it.

Generate EPUB *

jepub.generate(type = 'blob', onUpdate?: metadata => void)

Static methods +

Convert HTML to text

jEpub.html2text(htmlstring, noBr = false)
  • html: HTML string.
  • noBr: Boolean. Add line break after Block-level elements.

Development

npm start

Builds are concatenated and minified using Webpack and Babel.

npm run build

License

ISC. Copyright 2018 lelinhtinh

FOSSA Status

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.4
    24
    • latest

Version History

Package Sidebar

Install

npm i jepub

Weekly Downloads

41

Version

2.1.4

License

ISC

Unpacked Size

360 kB

Total Files

23

Last publish

Collaborators

  • baivong