Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
});
static getEpubWriter(metadata) {
// eslint-disable-next-line
const nodepub = require('nodepub');
return nodepub.document(
metadata,
metadata.coverPath || Book.DEFAULT_COVER_PATH,
Book.getToc
);
}
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) => {
console.log(e.stack);
reject(e);