summaryrefslogtreecommitdiff
path: root/spec2js.js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-21 22:29:16 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-08-13 22:56:32 -0700
commit870e63be7360b5a0097a27656048e853bc720464 (patch)
treee8f19ee2d62e529115cb71dcda5f3298cca7d389 /spec2js.js
parent650ad87f35f4405a2ca8270d2b2835daa442e5f1 (diff)
Initial commit
Diffstat (limited to 'spec2js.js')
-rwxr-xr-xspec2js.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec2js.js b/spec2js.js
new file mode 100755
index 0000000..6bf366f
--- /dev/null
+++ b/spec2js.js
@@ -0,0 +1,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');
+});