aboutsummaryrefslogtreecommitdiff
path: root/tools/spec2js.js
blob: 6bf366f97f0d2783e62c5017e2ccb32be3b8af77 (plain)
  1. #!/usr/bin/env node
  2. var fs = require('fs');
  3. var util = require('util');
  4. fs.readFile('spec.txt', 'utf8', function(err, data) {
  5. if (err) {
  6. return console.log(err);
  7. }
  8. var examples = [];
  9. data.replace(/^\.\n([\s\S]*?)^\.\n([\s\S]*?)^\.$/gm,
  10. function(_,x,y){
  11. examples.push({markdown: x, html: y});
  12. });
  13. console.log(util.inspect(examples, { depth: null }));
  14. console.warn(examples.length + ' examples');
  15. });