cmark

My personal build of CMark ✏️

Commit
cb553e8003aa748e20f7c3aeb93a75e5bbeeb23c
Parent
586d343d74de008d2ce62e15a5d153be173fd791
Author
John MacFarlane <jgm@berkeley.edu>
Date

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

Diffstat

1 file changed, 14 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified js/bin/commonmark 15 14 1
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