How to use nodepub - 3 common examples

To help you get started, we’ve selected a few nodepub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Racle / Reddit2Ebook / index.js View on Github external
async function generateEbook() {

    console.log("Creating ebook from: " +  subreddit +(comments_include ? " (comments enabled)" : ''));

    //creating custom cover with subreddit as text
    await createCover();
    epub = makepub.document(metadata, "./cover/cover.jpg");
    epub.addCSS("h1>a{color:inherit;text-decoration:none}.comment-parent{margin-left:0!important}.comment{margin-left:5px;padding-left:5px;border-left:1px solid gray;}");

    await getContent("https://old.reddit.com/" + subreddit + '/new.json?limit=10&sort=new');

    await epub.writeEPUB(function (e) {
        console.log("Error:", e);
    }, './output', subreddit.split("/").pop(), async function () {
        ora("EPUB created to output/" + subreddit.split("/").pop() + ".epub\n").start().succeed();


      // add "Press enter to continue..." after writing epub
      // this is for executables, so you can see what app created
      const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
      });
github haroldtreen / epub-press / lib / book.js View on Github external
static getEpubWriter(metadata) {
        // eslint-disable-next-line
        const nodepub = require('nodepub');
        return nodepub.document(
            metadata,
            metadata.coverPath || Book.DEFAULT_COVER_PATH,
            Book.getToc
        );
    }
github haroldtreen / epub-press / lib / epub-generator.js View on Github external
const generatedPromise = new Promise((resolve, reject) => {
            defaultMetadata.title = title;
            const ebook = nodepub.document(defaultMetadata, coverPath);

            console.log('Fetching HTML');
            Services.urlsToHtml(urls).then((htmls) => {
                console.log('Extracting Articles');
                return Services.extractArticles(htmls);
            }).then((articles) => {
                console.log('Converting to XHTML');
                return Services.articlesToXhtml(articles);
            }).then((articles) => {
                console.log('Creating Ebook');
                articles.forEach((article) => {
                    ebook.addSection(article.title, `<h1>${article.title}</h1>${article.content}`);
                });
                ebook.writeEPUB((e) =&gt; {
                    console.log(e.stack);
                    reject(e);

nodepub

Create valid EPUB (v2) ebooks with metadata, contents and cover image.

MIT
Latest version published 3 years ago

Package Health Score

36 / 100
Full package analysis

Popular nodepub functions