cmark

My personal build of CMark ✏️

Commit
604c15c301a634a7c237e2336296d2d86d771fcf
Parent
8e51ff90c5d6fb2b8c4cec54a77cfd45f7eb8e8f
Author
John MacFarlane <jgm@berkeley.edu>
Date

Rename sourcepos -> _sourcepos, added sourcepos() accessor.

Diffstat

4 files changed, 10 insertions, 6 deletions

Status File Name N° Changes Insertions Deletions
Modified js/lib/blocks.js 6 3 3
Modified js/lib/html.js 2 1 1
Modified js/lib/node.js 6 5 1
Modified js/lib/xml.js 2 1 1
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
@@ -432,7 +432,7 @@ var incorporateLine = function(ln) {
                    ((match = ln.slice(offset).match(reSetextHeaderLine)))) {
             // setext header line
             allClosed = allClosed || this.closeUnmatchedBlocks();
-            var header = new Node('Header', container.sourcepos);
+            var header = new Node('Header', container.sourcepos());
             header.level = match[0][0] === '=' ? 1 : 2;
             header.strings = container.strings;
             container.insertAfter(header);
@@ -510,7 +510,7 @@ var incorporateLine = function(ln) {
               (t === 'CodeBlock' && container.fence_length > 0) ||
               (t === 'Item' &&
                !container.firstChild &&
-               container.sourcepos[0][0] === this.lineNumber));
+               container.sourcepos()[0][0] === this.lineNumber));
 
         var cont = container;
         while (cont.parent) {
@@ -573,7 +573,7 @@ var finalize = function(block, lineNumber) {
         return 0;
     }
     block.open = false;
-    block.sourcepos[1] = [lineNumber, this.lastLineLength + 1];
+    block.sourcepos()[1] = [lineNumber, this.lastLineLength + 1];
 
     switch (block.type()) {
     case 'Paragraph':
diff --git a/js/lib/html.js b/js/lib/html.js
@@ -60,7 +60,7 @@ var renderNodes = function(block) {
 
         attrs = [];
         if (options.sourcepos) {
-            var pos = node.sourcepos;
+            var pos = node.sourcepos();
             if (pos) {
                 attrs.push(['data-sourcepos', String(pos[0][0]) + ':' +
                             String(pos[0][1]) + '-' + String(pos[1][0]) + ':' +
diff --git a/js/lib/node.js b/js/lib/node.js
@@ -69,7 +69,7 @@ var Node = function(nodeType, sourcepos) {
     this.lastChild = null;
     this.prev = null;
     this.next = null;
-    this.sourcepos = sourcepos;
+    this._sourcepos = sourcepos;
     this.last_line_blank = false;
     this.open = true;
     this.strings = null;
@@ -93,6 +93,10 @@ Node.prototype.type = function() {
     return this._type;
 };
 
+Node.prototype.sourcepos = function() {
+    return this._sourcepos;
+};
+
 Node.prototype.appendChild = function(child) {
     child.unlink();
     child.parent = this;
diff --git a/js/lib/xml.js b/js/lib/xml.js
@@ -123,7 +123,7 @@ var renderNodes = function(block) {
                 break;
             }
             if (options.sourcepos) {
-                var pos = node.sourcepos;
+                var pos = node.sourcepos();
                 if (pos) {
                     attrs.push(['data-sourcepos', String(pos[0][0]) + ':' +
                                 String(pos[0][1]) + '-' + String(pos[1][0]) + ':' +