Last active
September 29, 2016 03:42
-
-
Save rhysd/e589de862e610e3edd4fbc63475388de to your computer and use it in GitHub Desktop.
This file contains 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
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