npm.io
0.0.12-beta.4 • Published 2 months ago

@epubook/core

Licence
MIT
Version
0.0.12-beta.4
Deps
5
Size
21 kB
Vulns
0
Weekly
0
Stars
11

@epubook/core

version CI

The fundamental module of epubook. It provides low-level API for generating EPUB books.

Installation

npm i @epubook/core

Usage

import { Epub, HTML } from '@epubook/core'

const book = new Epub({
  title: 'Test Book',
  date: new Date('2023-02-01T11:00:00.000Z'),
  lastModified: new Date('2023-02-26T11:00:00.000Z'),
  creator: 'XLor',
  description: 'for test usage',
  source: 'imagine'
})

const page = new HTML('start.xhtml', '...')

book.item(page).spine(page).toc([{ title: 'Start', page }])

await book.writeFile('./test.epub')
JSX

You can use jsx to create XHTML node.

/** @jsxImportSource @epubook/xml */

import { XHTMLBuilder } from '@epubook/core'

const builder = new XHTMLBuilder()

const xhtml = builder
  .appendBody(<h1>Title</h1>)
  .appendBody(<p>This is a paragraph</p>)
  .build()

You can see @epubook/theme for more details.

License

MIT License 2023 XLor

Keywords