jdan / cleaver

30-second slideshows for hackers
http://jdan.github.io/cleaver
MIT License
4.02k stars 305 forks source link

how to use cleaver in express? #131

Closed ghost closed 8 years ago

ghost commented 8 years ago

how can i use the cleaver in Express as module?

jdan commented 8 years ago

Hey @CarlosRen,

Cleaver typically runs as a standalone program (from the command-line), though there is nothing stopping you from using it's undocumented API!

Look at bin/cleaver for inspiration:

var presentation = new Cleaver(contents, options, path.resolve(path.dirname(file)));
presentation.run()
    .then(function (product) {
        var outputFile = presentation.options.output || path.basename(file, '.md') + '-cleaver.html';
        fs.writeFile(outputFile, product);
    })
    .fail(function (err) {
        process.stderr.write('!! ' + err.message + '\n');
        if (program.debug) {
            process.stderr.write(err.stack);
        }
        process.exit(1);
    });

Does that sort of make sense? I'd love to help you get something working.