cmark

My personal build of CMark ✏️

Commit
9d005eab33db7b31edca49982398c666ccc27567
Parent
0d9c230a46f1bf79d4be81cb42cfaebc6f5b5ced
Author
John MacFarlane <jgm@berkeley.edu>
Date

Don't initialize strings, string_content to defined value.

Diffstat

2 files changed, 13 insertions, 4 deletions

Status File Name N° Changes Insertions Deletions
Modified js/lib/blocks.js 13 11 2
Modified js/lib/node.js 4 2 2
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
@@ -137,6 +137,8 @@ var addChild = function(tag, line_number, offset) {
 
     var column_number = offset + 1; // offset 0 = column 1
     var newBlock = new Node(tag, { start: [line_number, column_number], end: [] });
+    newBlock.strings = [];
+    newBlock.string_content = "";
     this.tip.appendChild(newBlock);
     this.tip = newBlock;
     return newBlock;
@@ -635,10 +637,17 @@ var processInlines = function(block) {
     }
 };
 
+var Document = function() {
+    var doc = new Node('Document', { start: [1, 1], end: [] });
+    doc.string_content = "";
+    doc.strings = [];
+    return doc;
+};
+
 // The main parsing function.  Returns a parsed document AST.
 var parse = function(input) {
     "use strict";
-    this.doc = new Node('Document', { start: [1, 1], end: [] });
+    this.doc = Document();
     this.tip = this.doc;
     this.refmap = {};
     var lines = input.replace(/\n$/, '').split(/\r\n|\n|\r/);
@@ -658,7 +667,7 @@ var parse = function(input) {
 function DocParser(){
     "use strict";
     return {
-        doc: new Node('Document', { start: [1, 1], end: [] }),
+        doc: Document(),
         tip: this.doc,
         refmap: {},
         inlineParser: new InlineParser(),
diff --git a/js/lib/node.js b/js/lib/node.js
@@ -70,8 +70,8 @@ function Node(nodeType, pos) {
     this.pos = pos || {};
     this.last_line_blank = false;
     this.open = true;
-    this.strings = [];
-    this.string_content = "";
+    this.strings = undefined;
+    this.string_content = undefined;
     this.c = undefined;
     this.list_data = undefined;
     this.info = undefined;