summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-15 14:17:27 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-15 14:17:27 -0800
commit604c15c301a634a7c237e2336296d2d86d771fcf (patch)
tree4eb045fcf90d614c15290247f66656c49afe81a4
parent8e51ff90c5d6fb2b8c4cec54a77cfd45f7eb8e8f (diff)
Rename sourcepos -> _sourcepos, added sourcepos() accessor.
-rw-r--r--js/lib/blocks.js6
-rw-r--r--js/lib/html.js2
-rw-r--r--js/lib/node.js6
-rw-r--r--js/lib/xml.js2
4 files changed, 10 insertions, 6 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index 0224f74..d5ad49e 100644
--- 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
index e39b4ac..608193d 100644
--- 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
index 8e424a2..3041f15 100644
--- 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
index 64422c9..d7f732c 100644
--- 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]) + ':' +