From 675c2640755ecf3fa7978e16d61261f64fd75e65 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 9 Jan 2015 17:27:44 -0800 Subject: 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. --- js/lib/blocks.js | 15 +++++++++------ js/lib/html.js | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'js') 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; -- cgit v1.2.3