cmark

My personal build of CMark ✏️

Commit
a17a86cbcfb2a4775638c00bca83e54d4ee5f30f
Parent
d307c3eb1b9ff81d929755ac293ad50ef49c6a74
Author
John MacFarlane <jgm@berkeley.edu>
Date

node.js: toAST -> toObject.

Diffstat

2 files changed, 5 insertions, 5 deletions

Status File Name N° Changes Insertions Deletions
Modified js/bin/commonmark 2 1 1
Modified js/lib/node.js 8 4 4
diff --git a/js/bin/commonmark b/js/bin/commonmark
@@ -39,7 +39,7 @@ if (format === 'html') {
     renderer = new commonmark.XmlRenderer(options);
 } else if (format === 'ast') {
     renderer = { render: function(node) {
-                   return util.inspect(node.toAST(), null, 20, true) + '\n';
+                   return util.inspect(node.toObject(), null, 20, true) + '\n';
                  },
                  options: {} };
 }
diff --git a/js/lib/node.js b/js/lib/node.js
@@ -164,7 +164,7 @@ Node.prototype.walker = function() {
     return walker;
 };
 
-var toASTNode = function(node) {
+var nodeToObject = function(node) {
     var result = {};
     var propsToShow = ['t', 'literal', 'list_data', 'sourcepos',
                        'info', 'level', 'title', 'destination'];
@@ -178,7 +178,7 @@ var toASTNode = function(node) {
     return result;
 };
 
-Node.prototype.toAST = function() {
+Node.prototype.toObject = function() {
     var childrenStack = [];
     var walker = this.walker();
     var event;
@@ -192,14 +192,14 @@ Node.prototype.toAST = function() {
             if (entering) {
                 childrenStack.push([]);
             } else {
-                astnode = toASTNode(node);
+                astnode = nodeToObject(node);
                 astnode.children = childrenStack.pop();
                 if (childrenStack.length > 0) {
                     childrenStack[childrenStack.length - 1].push(astnode);
                 }
             }
         } else {
-            astnode = toASTNode(node);
+            astnode = nodeToObject(node);
             childrenStack[childrenStack.length - 1].push(astnode);
         }
     }