cmark

Unnamed repository; edit this file 'description' to name the repository.

commit cb553e8003aa748e20f7c3aeb93a75e5bbeeb23c
parent 586d343d74de008d2ce62e15a5d153be173fd791
Author: John MacFarlane <jgm@berkeley.edu>
Date:   Sat, 10 Jan 2015 17:51:38 -0800

Added --time option to js/bin/commonmark.

Diffstat:
Mjs/bin/commonmark | 15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/js/bin/commonmark b/js/bin/commonmark
@@ -9,12 +9,15 @@ var file;
 var files = [];
 var options = { sourcepos: false };
 var format = 'html';
+var time = false;
 var i;
 
 for (i = 2; i < process.argv.length; i++) {
     var arg = process.argv[i];
     if (arg === '--ast') {
         format = 'ast';
+    } else if (arg === '--time') {
+        time = true;
     } else if (arg === '--sourcepos') {
         options.sourcepos = true;
     } else if (/^--/.test(arg)) {
@@ -44,4 +47,13 @@ for (i = 0; i < files.length; i++) {
   inps.push(fs.readFileSync(file, 'utf8'));
 }
 
-process.stdout.write(renderer.render(parser.parse(inps.join('\n'))));
+var inp = inps.join('\n');
+if (time) { console.time("parsing"); }
+var doc = parser.parse(inp);
+if (time) { console.timeEnd("parsing"); }
+
+if (time) { console.time("rendering"); }
+var rendered = renderer.render(doc);
+if (time) { console.timeEnd("rendering"); }
+
+if (!time) { process.stdout.write(rendered); }+
\ No newline at end of file