aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2015-01-09 17:27:44 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2015-01-09 17:27:44 -0800
commit675c2640755ecf3fa7978e16d61261f64fd75e65 (patch)
tree51412ae13f039e62c22e110aef700fdd8f19ba95
parentb7b5340c844f4016a1089053924dd8f92118d21f (diff)
JS: use c rather than string_content property for code blocks, html.
string_content is just for the raw string content that will be parsed as inlines, not for the 'real' content of the block element.
-rw-r--r--js/lib/blocks.js15
-rw-r--r--js/lib/html.js4
2 files changed, 11 insertions, 8 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index f99aef1..7972b09 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -138,7 +138,7 @@ 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 = "";
+ newBlock.string_content = undefined;
this.tip.appendChild(newBlock);
this.tip = newBlock;
return newBlock;
@@ -571,12 +571,15 @@ var finalize = function(block, line_number) {
break;
case 'Header':
- case 'HtmlBlock':
block.string_content = block.strings.join('\n');
break;
+ case 'HtmlBlock':
+ block.c = block.strings.join('\n');
+ break;
+
case 'IndentedCode':
- block.string_content = block.strings.join('\n').replace(/(\n *)*$/, '\n');
+ block.c = block.strings.join('\n').replace(/(\n *)*$/, '\n');
block.t = 'CodeBlock';
break;
@@ -584,9 +587,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.string_content = '';
+ block.c = '';
} else {
- block.string_content = block.strings.slice(1).join('\n') + '\n';
+ block.c = block.strings.slice(1).join('\n') + '\n';
}
block.t = 'CodeBlock';
break;
@@ -639,7 +642,7 @@ var processInlines = function(block) {
var Document = function() {
var doc = new Node('Document', { start: [1, 1], end: [] });
- doc.string_content = "";
+ doc.string_content = undefined;
doc.strings = [];
return doc;
};
diff --git a/js/lib/html.js b/js/lib/html.js
index 1f1b0ba..57f87e5 100644
--- a/js/lib/html.js
+++ b/js/lib/html.js
@@ -184,14 +184,14 @@ var renderNodes = function(block) {
? [] : [['class', 'language-' + esc(info_words[0], true)]];
cr();
out(tag('pre') + tag('code', attrs));
- out(this.escape(node.string_content));
+ out(this.escape(node.c));
out(tag('/code') + tag('/pre'));
cr();
break;
case 'HtmlBlock':
cr();
- out(node.string_content);
+ out(node.c);
cr();
break;