summaryrefslogtreecommitdiff
path: root/tools/spec2js.js
blob: 6bf366f97f0d2783e62c5017e2ccb32be3b8af77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env node

var fs = require('fs');
var util = require('util');

fs.readFile('spec.txt', 'utf8', function(err, data) {
  if (err) {
    return console.log(err);
  }
  var examples = [];
  data.replace(/^\.\n([\s\S]*?)^\.\n([\s\S]*?)^\.$/gm,
        function(_,x,y){
          examples.push({markdown: x, html: y});
      });
  console.log(util.inspect(examples, { depth: null }));
  console.warn(examples.length + ' examples');
});