43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const { Notebook } = require("crossnote")
|
|
const path = require('path')
|
|
const fs = require('fs')
|
|
|
|
async function main() {
|
|
const notebook = await Notebook.init(
|
|
{
|
|
notebookPath: path.resolve(''),
|
|
config: {
|
|
previewTheme: 'github-light.css',
|
|
mathRenderingOption: 'KaTeX',
|
|
codeBlockTheme: 'github.css',
|
|
printBackground: true,
|
|
enableScriptExecution: true,
|
|
|
|
chromePath: '/usr/bin/google-chrome-stable',
|
|
},
|
|
}
|
|
);
|
|
const files = fs.readdirSync(path.resolve('notes')).filter(file => {
|
|
return path.extname(file).toLowerCase() == '.md';
|
|
});
|
|
|
|
files.forEach(async (file) => {
|
|
const fileBase = "notes/" +path.basename(file);
|
|
const fileName = path.basename(file, ".md")
|
|
console.log("found " + fileBase);
|
|
const engine = notebook.getNoteMarkdownEngine(fileBase);
|
|
await engine.chromeExport({ runAllCodeChunks: true });
|
|
|
|
const old = path.resolve('notes', fileName + ".pdf");
|
|
const dest = path.resolve('out', 'notes', fileName + ".pdf");
|
|
|
|
fs.rename(old, dest, (err) => {
|
|
if (err) throw err;
|
|
console.log(fileName + ".pdf" + " moved to out completed");
|
|
});;
|
|
});
|
|
|
|
|
|
}
|
|
|
|
main(); |