Skip to content

heng1025/epub-parse

Repository files navigation

parse epub files(just epub xml,never .epub file)

Install

npm install https://github.com/heng1025/epub-parse.git

How To Use

1.weixin miniprogram

import { parseEpubBook, loadEpubChapter, Epub } from '@heng1025/epub-parse';
  1. browser
<script src="../dist/index.umd.min.js"></script>
<script>
// ...global Epub
const {spine, manifest,packageDirectory,toc} = await Epub.parseEpubBook(epubUri);
let { rawTexts } = await Epub.loadEpubChapter(epub,chapterCount);
// ...
<script>

API

  1. parseEpubBook
function parseEpubBook(
  rootURL: string,
): Promise<{
  spine: Array<any>;
  manifest: Array<any>;
  packageDirectory: string;
  toc: Array<any>;
}>;
  1. loadEpubChapter
export function loadEpubChapter(
  epub: Epub,
  chapterCount: number,
): Promise<{ rawText: string; formatTexts: string }>;
params description
epubUri container.xm path of epub file

reference https://github.com/dariocravero/parse-epub.git

dev

yarn demo
yarn watch