npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

r2epub

v1.3.2

Published

Typescript based conversion of Respec generated HTML files into EPUB 3.3

Downloads

12

Readme

ReSpec to EPUB

Typescript program to convert W3C documents, produced by ReSpec, to EPUB 3.3.

Single documents vs. Collections

The conversion can:

  • Convert a single HTML source that was produced by ReSpec.
  • Convert a single HTML source that must be pre-processed by ReSpec to get its final formats; the program pre-processes the source on the fly.
  • Convert and combine a “collection“ of HTML sources (to be pre-processed or not) into a single EPUB 3 instance.

(The on-the-fly conversion via ReSpec is done by running the W3C’s Spec Generator service. Alas!, that service may be down or slow, and this package has no control over that…)

Package usage

Command line usage

There is a simple command line interface to run the script. See the the separate documentation on cli for details and examples.

Run a service via HTTP

There is also the possibility to start a simple server to generate EPUB 3.3 instances on request. See the separate documentation on the server for details and examples of HTTP requests.

The server has been deployed on the cloud at W3C using the https://labs.w3.org/r2epub URL. A browser interface to drive this server is also available.

(Note that the server running on W3C is used to generate an EPUB version of a document based on respec, using its export facility.)

Use as a typescript/node package through an API

The program can also be used from another Typescript or Javascript program. See the separate documentation on the API for details and examples of the API usage.

Installation, usage

The implementation is in Typescript and on top of node.js. The documentation is also available on-line.

Installation

The usual npm approach applies:

git clone https://github.com/iherman/r2epub.git
cd r2epub
npm install

or simply use

npm install r2epub

to get to the latest, published version.

The repository contains both the typescript code (in the src directory) as well as the transformed javascript code (in the dist directory). If, for some reasons, the latter is not in the repository or is not up to date, the

npm run build

command takes care of that. The documentation can also be generated locally through the

npm run docs

command.

Environment variables

  • PORT or R2EPUB_PORT: the port number used by the server; failing these the default (i.e., 80) is used. (PORT takes precedence over R2EPUB_PORT.)

  • R2EPUB_LOCAL: no URL-s on localhost are accepted, unless this environment variable set (the value of the variable is not relevant, only the setting is). For security reasons this variable should not be set for deployed servers.

  • R2EPUB_MODIFIED_EPUB_FILES: A number of W3C specific files (logos, some css files) had to be adapted for EPUB 3 usage, and are retrieved from a separate site. At the moment, https://www.ivan-herman.net/r2epub/ is used as a base URL for those files. However, if the variable is set, its value is used as a prefix for the copy of the files on the local file system and the files are read directly from the disc. (Typically, the value points at docs/epub_assets/ in the local clone of the distribution.)

    (Some server may have problems with a burst of access to the same base URL resulting in run-time error, hence the advantage to use this local alternative to setup.)

Usage

Once installed locally, follow specific instructions based on your needs/interest below:

Command Line

node dist/r2epub.js

starts the command line interface.

Server

node dist/server.js

starts up the server locally.


Copyright © 2020 Ivan Herman (a.k.a. @iherman).