-
-
Save jsmayo/0747f9238a7f36e1c1b9dc1f86ca2646 to your computer and use it in GitHub Desktop.
Output pandoc command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just run node pandoc-build.js > output.txt | |
// that will write the contents of this there | |
// and then just copy paste that command and | |
// you should get a good epub. | |
// I always had to cd to the root of the posts | |
// directory to run the command. | |
var fs = require('fs'); | |
var path = require('path'); | |
var output = [ | |
"pandoc -o _book.epub \\\n", | |
"--toc \\\n", | |
"--toc-depth=1 \\\n", | |
"--epub-cover-image=adi-goldstein-257316-unsplash.jpg \\\n", | |
"title.md \\\n" | |
]; | |
var pathsForImages = [".","."]; | |
var blogFolders = "./blog" | |
fs.readdir(blogFolders, function (err, folders) { | |
if (err) { | |
console.error("Could not list directory", err); | |
} | |
folders.forEach(function (folder, index) { | |
var folderPath = path.join(blogFolders, folder); | |
fs.stat(folderPath, function (error, stat) { | |
if (error) { | |
console.error('Stat error', error); | |
} | |
if (stat.isDirectory()) { | |
//console.log('adding ' + folderPath); | |
output.push(folderPath + "/index.md \\\n") | |
pathsForImages.push(folderPath); | |
} | |
//console.log(index + ' / ' + folders.length); | |
if(index == (folders.length-1)){ | |
pathsForImages = pathsForImages.join(":"); | |
pathsForImages = pathsForImages.replace(/\\/gm,'/'); | |
output = output.join(" "); | |
output += " --resource-path=" + pathsForImages; | |
output = output.replace(/\sblog\\/gm, 'blog/'); | |
output = output.replace(/\s\n\s\\/gm, '\n'); | |
console.log(output); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment