Skip to content

Instantly share code, notes, and snippets.

@rhysd
Last active September 29, 2016 03:42
Show Gist options
  • Save rhysd/e589de862e610e3edd4fbc63475388de to your computer and use it in GitHub Desktop.
Save rhysd/e589de862e610e3edd4fbc63475388de to your computer and use it in GitHub Desktop.
const fs = require('fs');
const parse = require('remark-parse');
const slug = require('remark-slug');
const headings = require('remark-autolink-headings');
const github = require('remark-github');
const toc = require('remark-toc');
const unified = require('unified');
function dump(processor, options) {
class Compiler {
compile(node) {
return JSON.stringify(node, null, 2);
}
}
processor.Compiler = Compiler;
}
unified().use([
parse,
dump,
toc,
slug,
headings,
github
]).process(fs.readFileSync(process.argv[2]), (err, ret) => {
if (err) {
console.error(err.message);
return;
}
console.log(ret.contents);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment