cmark

Unnamed repository; edit this file 'description' to name the repository.

commit 675c2640755ecf3fa7978e16d61261f64fd75e65
parent b7b5340c844f4016a1089053924dd8f92118d21f
Author: John MacFarlane <fiddlosopher@gmail.com>
Date:   Fri,  9 Jan 2015 17:27:44 -0800

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.

Diffstat:
Mjs/lib/blocks.js | 15+++++++++------
Mjs/lib/html.js | 4++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git 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
@@ -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;