aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/spec2js.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/spec2js.js b/tools/spec2js.js
new file mode 100755
index 0000000..6bf366f
--- /dev/null
+++ b/tools/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');
+});