aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-09 19:15:07 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-09 19:15:07 -0800
commit8c7ca2e30044925bcf611ddc816580d6746c7101 (patch)
tree299514669c39db05525370021b335875911f5d28 /js
parenta1bc760fef3ae9e98f039fa50f31fc2d5eb877a2 (diff)
JS: Renamed 'c' property to 'literal' to match libcmark.
Diffstat (limited to 'js')
-rw-r--r--js/lib/blocks.js8
-rw-r--r--js/lib/html.js10
-rw-r--r--js/lib/inlines.js20
-rw-r--r--js/lib/node.js5
4 files changed, 24 insertions, 19 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index a83bccf..f948e8b 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -572,11 +572,11 @@ var finalize = function(block, line_number) {
break;
case 'HtmlBlock':
- block.c = block.strings.join('\n');
+ block.literal = block.strings.join('\n');
break;
case 'IndentedCode':
- block.c = block.strings.join('\n').replace(/(\n *)*$/, '\n');
+ block.literal = block.strings.join('\n').replace(/(\n *)*$/, '\n');
block.t = 'CodeBlock';
break;
@@ -584,9 +584,9 @@ var finalize = function(block, line_number) {
// first line becomes info string
block.info = unescapeString(block.strings[0].trim());
if (block.strings.length === 1) {
- block.c = '';
+ block.literal = '';
} else {
- block.c = block.strings.slice(1).join('\n') + '\n';
+ block.literal = block.strings.slice(1).join('\n') + '\n';
}
block.t = 'CodeBlock';
break;
diff --git a/js/lib/html.js b/js/lib/html.js
index ca5b477..ce9b836 100644
--- a/js/lib/html.js
+++ b/js/lib/html.js
@@ -61,7 +61,7 @@ var renderNodes = function(block, options) {
switch (node.t) {
case 'Text':
- out(esc(node.c));
+ out(esc(node.literal));
break;
case 'Softbreak':
@@ -86,7 +86,7 @@ var renderNodes = function(block, options) {
break;
case 'Html':
- out(node.c);
+ out(node.literal);
break;
case 'Link':
@@ -120,7 +120,7 @@ var renderNodes = function(block, options) {
break;
case 'Code':
- out(tag('code') + esc(node.c) + tag('/code'));
+ out(tag('code') + esc(node.literal) + tag('/code'));
break;
case 'Document':
@@ -198,14 +198,14 @@ var renderNodes = function(block, options) {
}
cr();
out(tag('pre') + tag('code', attrs));
- out(this.escape(node.c));
+ out(this.escape(node.literal));
out(tag('/code') + tag('/pre'));
cr();
break;
case 'HtmlBlock':
cr();
- out(node.c);
+ out(node.literal);
cr();
break;
diff --git a/js/lib/inlines.js b/js/lib/inlines.js
index 70247cd..adeac6c 100644
--- a/js/lib/inlines.js
+++ b/js/lib/inlines.js
@@ -90,7 +90,7 @@ var normalizeReference = function(s) {
var text = function(s) {
"use strict";
var node = new Node('Text');
- node.c = s;
+ node.literal = s;
return node;
};
@@ -150,7 +150,7 @@ var parseBackticks = function(block) {
while (!foundCode && (matched = this.match(/`+/m))) {
if (matched === ticks) {
node = new Node('Code');
- node.c = this.subject.slice(afterOpenTicks,
+ node.literal = this.subject.slice(afterOpenTicks,
this.pos - ticks.length)
.replace(/[ \n]+/g, ' ')
.trim();
@@ -222,7 +222,7 @@ var parseHtmlTag = function(block) {
var node;
if (m) {
node = new Node('Html');
- node.c = m;
+ node.literal = m;
block.appendChild(node);
return true;
} else {
@@ -358,8 +358,12 @@ var processEmphasis = function(block, stack_bottom) {
// remove used delimiters from stack elts and inlines
opener.numdelims -= use_delims;
closer.numdelims -= use_delims;
- opener_inl.c = opener_inl.c.slice(0, opener_inl.c.length - use_delims);
- closer_inl.c = closer_inl.c.slice(0, closer_inl.c.length - use_delims);
+ opener_inl.literal =
+ opener_inl.literal.slice(0,
+ opener_inl.literal.length - use_delims);
+ closer_inl.literal =
+ closer_inl.literal.slice(0,
+ closer_inl.literal.length - use_delims);
// build contents for new emph element
var emph = new Node(use_delims === 1 ? 'Emph' : 'Strong');
@@ -673,9 +677,9 @@ var parseNewline = function(block) {
// check previous node for trailing spaces
var lastc = block.lastChild;
if (lastc && lastc.t === 'Text') {
- var sps = / *$/.exec(lastc.c)[0].length;
+ var sps = / *$/.exec(lastc.literal)[0].length;
if (sps > 0) {
- lastc.c = lastc.c.replace(/ *$/,'');
+ lastc.literal = lastc.literal.replace(/ *$/,'');
}
block.appendChild(new Node(sps >= 2 ? 'Hardbreak' : 'Softbreak'));
} else {
@@ -792,7 +796,7 @@ var parseInline = function(block) {
if (!res) {
this.pos += 1;
var textnode = new Node('Text');
- textnode.c = fromCodePoint(c);
+ textnode.literal = fromCodePoint(c);
block.appendChild(textnode);
}
diff --git a/js/lib/node.js b/js/lib/node.js
index 102003c..e57a281 100644
--- a/js/lib/node.js
+++ b/js/lib/node.js
@@ -72,7 +72,7 @@ function Node(nodeType, sourcepos) {
this.open = true;
this.strings = undefined;
this.string_content = undefined;
- this.c = undefined;
+ this.literal = undefined;
this.list_data = undefined;
this.info = undefined;
this.destination = undefined;
@@ -167,7 +167,8 @@ Node.prototype.toAST = function() {
var cur;
var result = { t: this.t };
- var propsToShow = ['t', 'c', 'list_data', 'sourcepos', 'info', 'level'];
+ var propsToShow = ['t', 'literal', 'list_data', 'sourcepos',
+ 'info', 'level'];
for (var i = 0; i < propsToShow.length; i++) {
var prop = propsToShow[i];