epubify

Generate an ePub book from a simple plaintext descriptor.

Usage no npm install needed!

<script type="module">
  import epubify from 'https://cdn.skypack.dev/epubify';
</script>

README

gen-epub-book.js Build Status Licence npm version

Generate an ePub book from a simple plaintext descriptor.

Manpage

Browserified bundles

Quickstart

Install via:

npm install -g epubify

Copy this somewhere:

Name: Simple ePub demonstration
Cover: cover.png

Image-Content: simple/chapter_image.png
Content: simple/ctnt.html

Author: nabijaczleweli
Date: 2017-02-08T15:30:18+01:00
Language: en-GB

Modify to your liking, then, assuming you put the file in "example/test.epupp" and want to write the result to "out/test.epub", run:

epubify example/test.epupp out/test.epub

For more detailed usage information and tag list, see the manpage, and for a full guide see the webpage.

Versions in other languages

The original in AWK.

A rewrite in Rust.

A rewrite in C++.

A rewrite in Scala.

Documentation

BookError

Extends Error

Generic book parsing error.

parse_descriptor(string_contents, relative_root)

Parse specified file content into a Book instance.

Parameters

  • string_contents string the content of the specified file
  • relative_root string

Returns Book

util.RFC3339_FORMAT

Format string to parse RFC3339 with moment.

Type: string

util.CHAPTER_TITLE_REGEX

Regex for extracting chapter titles.

Type: RegExp

util.file_exists(path)

Check whether a file with the specified path exists.

Parameters

  • path string The file for whose existence to check.

Returns boolean Whether the specified file exists.

util.string_content(content)

Get content of string-content, having provided the content of that string-content (yes).

Parameters

  • content string String data of that string content.

Returns string String content to include in e-book.

util.image_content_string(img_path)

Get img filler for image-content.

For full image string content one need do epubify.util.string_content(util.image_content_string(img_path)).

Parameters

  • img_path string Packed path of image.

Returns string Stringified <img> tag.

util.file_id(file_path)

Get e-book ID for the specified relative path.

Parameters

  • file_path string Pathname specified in "Content" key.

Returns string E-book ID to use for content.

util.file_packed_path(file_path)

Get packed e-book path for the specified relative path.

Parameters

  • file_path string Pathname specified in "Content" key.

Returns string E-book path to use for content.

util.url_id(url, file_path)

Get e-book ID for the specified URL.

Parameters

  • url URL
  • file_path Pathname specified in "Remote-*" key.

Returns string E-book ID to use for content.

util.url_packed_path(url)

Get packed e-book path for the specified URL.

Parameters

  • url URL Pathname specified in "Remote-*" key.

Returns string E-book path to use for content.

util.get_mime_for(pathname)

Get MIME-type for the specified MIME type.

Parameters

  • pathname string File to get MIME type for.

Returns string MIME type for that file.

class Configuration(argv[, out])

A unified config.

Constructor: parse commandline arguments.

Parameters

  • argv Array<string> command-line argument array without executable nor script name.
  • out Console (optional, default: global console object)
Configuration.in_file

The descriptor file to read from.

Type: string

Configuration.out_file

The file to which output the resulting ePub.

Type: string

Configuration.rel_root

Relative root for file paths.

Type: string

Configuration.separator

Separator for keys/values.

Default: ":".

Type: string

Configuration.free_date

Whether to try to parse non-RFC3339 date formats.

Default: false.

Type: boolean