initial commit
This commit is contained in:
commit
5a3d84924a
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
|
@ -0,0 +1,34 @@
|
||||||
|
const AP = require('article-parser');
|
||||||
|
var nodePandoc = require('node-pandoc-promise');
|
||||||
|
|
||||||
|
const url = process.argv[2];
|
||||||
|
|
||||||
|
const getArticle = async (url) => {
|
||||||
|
try {
|
||||||
|
const article = await AP.extract(url);
|
||||||
|
return article;
|
||||||
|
} catch (err) {
|
||||||
|
console.trace(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getArticle(url).then(res=>{
|
||||||
|
|
||||||
|
`
|
||||||
|
<dc:title id="epub-title-1">${res.title}</dc:title>
|
||||||
|
<dc:date>${res.published}</dc:date>
|
||||||
|
<dc:language>en-US</dc:language>
|
||||||
|
<dc:creator id="epub-creator-1" opf:role="aut">${res.author}</dc:creator>
|
||||||
|
`
|
||||||
|
|
||||||
|
// TODO: Write res.content into a temp file
|
||||||
|
|
||||||
|
const imageUrl = res.image
|
||||||
|
|
||||||
|
nodePandoc(tmpFile, ['-o', 'filel.epub', '--epbu-cover-image', 'file.png', '--epub-metadata=something.xml'])
|
||||||
|
.then(res=>{
|
||||||
|
console.log(res);
|
||||||
|
}).catch(err=>{
|
||||||
|
console.error('Oh No: ',err);
|
||||||
|
});
|
||||||
|
})
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "url-to-epub",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A single tool to generate a compliant EPUB from a webpage. Zero config. Requires pandoc",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Nemo",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"article-parser": "^4.1.1",
|
||||||
|
"node-pandoc-promise": "0.0.6"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue