cmark

My personal build of CMark ✏️

Commit
11a7287be0f5040f4cff4415466d04604b7b5015
Parent
3c35be821183a4f38bfd4d2feea4a8a215559b1d
Author
John MacFarlane <fiddlosopher@gmail.com>
Date

Removed JS library's dependency on util.

This reduces js/commonmark.js size by 20K.

Diffstat

3 files changed, 7 insertions, 17 deletions

Status File Name N° Changes Insertions Deletions
Modified dingus.html 3 1 2
Modified js/bin/commonmark 10 6 4
Modified js/lib/index.js 11 0 11
diff --git a/dingus.html b/dingus.html
@@ -10,7 +10,6 @@
   <script type="text/javascript">
 
 var writer = new commonmark.HtmlRenderer();
-var astwriter = new commonmark.ASTRenderer();
 var reader = new commonmark.DocParser();
 
 function getQueryVariable(variable) {
@@ -58,7 +57,7 @@ $(document).ready(function() {
     var renderTime = endTime - startTime;
     $("#preview").html(result);
     $("#html").text(result);
-    $("#ast").text(astwriter.render(parsed));
+    $("#ast").text("UNDER CONSTRUCTION"); // TODO - replace with xml
     $("#rendertime").text(renderTime);
   };
   var parseAndRender = function() {
diff --git a/js/bin/commonmark b/js/bin/commonmark
@@ -1,6 +1,7 @@
 #!/usr/bin/env node
 "use strict";
 
+var util = require('util');
 var fs = require('fs');
 var commonmark = require('../lib/index.js');
 
@@ -37,8 +38,10 @@ if (format === 'html') {
 } else if (format === 'xml') {
     renderer = new commonmark.XMLRenderer(options);
 } else if (format === 'ast') {
-    renderer = new commonmark.ASTRenderer(options);
-    renderer.options.colors = true;
+    renderer = { render: function(node) {
+                   return util.inspect(node.toAST(), null, 20, true) + '\n';
+                 },
+                 options: {} };
 }
 
 if (files.length === 0) {
@@ -55,4 +58,4 @@ var doc = parser.parse(inp);
 
 var rendered = renderer.render(doc);
 
-if (!options.time) { process.stdout.write(rendered); }-
\ No newline at end of file
+if (!options.time) { process.stdout.write(rendered); }
diff --git a/js/lib/index.js b/js/lib/index.js
@@ -11,18 +11,7 @@
 
 "use strict";
 
-var util = require('util');
-
 module.exports.Node = require('./node');
 module.exports.DocParser = require('./blocks');
 module.exports.HtmlRenderer = require('./html');
 module.exports.XMLRenderer = require('./xml');
-module.exports.ASTRenderer = function(options) {
-    return {
-        render: function(tree) {
-            return util.inspect(tree.toAST(), null, 20,
-                                this.options.colors) + '\n';
-        },
-        options: options || {}
-    };
-}