cmark

My personal build of CMark ✏️

Commit
f3b4629e5765b8a3762d129a92e3b270b953356d
Parent
a8c616ba29391c0ea8e20b2a240a72c05a3f0881
Author
John MacFarlane <jgm@berkeley.edu>
Date

More js delinting.

Diffstat

3 files changed, 14 insertions, 14 deletions

Status File Name N° Changes Insertions Deletions
Modified js/lib/blocks.js 11 6 5
Modified js/lib/html-renderer.js 14 7 7
Modified js/lib/inlines.js 3 1 2
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
@@ -120,7 +120,7 @@ var breakOutOfLists = function(block, line_number) {
 var addLine = function(ln, offset) {
     var s = ln.slice(offset);
     if (!(this.tip.open)) {
-        throw({ msg: "Attempted to add line (" + ln + ") to closed container." });
+        throw { msg: "Attempted to add line (" + ln + ") to closed container." };
     }
     this.tip.strings.push(s);
 };
@@ -310,12 +310,13 @@ var incorporateLine = function(ln, line_number) {
     // want to close unmatched blocks.  So we store this closure for
     // use later, when we have more information.
     var closeUnmatchedBlocks = function(mythis) {
+        var already_done = false;
         // finalize any blocks not matched
         while (!already_done && oldtip !== last_matched_container) {
             mythis.finalize(oldtip, line_number);
             oldtip = oldtip.parent;
         }
-        var already_done = true;
+        already_done = true;
     };
 
     // Check to see if we've hit 2nd blank line; if so break out of list:
@@ -508,7 +509,7 @@ var incorporateLine = function(ln, line_number) {
             if (acceptsLines(container.t)) {
                 this.addLine(ln, first_nonspace);
             } else if (blank) {
-                // do nothing
+                break;
             } else if (container.t !== 'HorizontalRule' &&
                        container.t !== 'Header') {
                 // create paragraph container for line
@@ -544,7 +545,7 @@ var finalize = function(block, line_number) {
 
     switch (block.t) {
     case 'Paragraph':
-        block.string_content = block.strings.join('\n').replace(/^  */m,'');
+        block.string_content = block.strings.join('\n').replace(/^ {2,}/m,'');
         // delete block.strings;
 
         // try parsing the beginning as link reference definitions:
@@ -669,7 +670,7 @@ var parse = function(input) {
     var lines = input.replace(/\n$/,'').split(/\r\n|\n|\r/);
     var len = lines.length;
     for (var i = 0; i < len; i++) {
-        this.incorporateLine(lines[i], i+1);
+        this.incorporateLine(lines[i], i + 1);
     }
     while (this.tip) {
         this.finalize(this.tip, len - 1);
diff --git a/js/lib/html-renderer.js b/js/lib/html-renderer.js
@@ -28,7 +28,7 @@ var renderInline = function(inline) {
     case 'Softbreak':
         return this.softbreak;
     case 'Hardbreak':
-        return inTags('br',[],"",true) + '\n';
+        return inTags('br', [], "", true) + '\n';
     case 'Emph':
         return inTags('em', [], this.renderInlines(inline.c));
     case 'Strong':
@@ -61,7 +61,7 @@ var renderInline = function(inline) {
 // Render a list of inlines.
 var renderInlines = function(inlines) {
     var result = '';
-    for (var i=0; i < inlines.length; i++) {
+    for (var i = 0; i < inlines.length; i++) {
         result = result + this.renderInline(inlines[i]);
     }
     return result;
@@ -97,8 +97,8 @@ var renderBlock = function(block, in_tight_list) {
         }
         return inTags('li', [], contents, false).trim();
     case 'List':
-        tag = block.list_data.type == 'Bullet' ? 'ul' : 'ol';
-        attr = (!block.list_data.start || block.list_data.start == 1) ?
+        tag = block.list_data.type === 'Bullet' ? 'ul' : 'ol';
+        attr = (!block.list_data.start || block.list_data.start === 1) ?
             [] : [['start', block.list_data.start.toString()]];
         return inTags(tag, attr, this.innersep +
                       this.renderBlocks(block.children, block.tight) +
@@ -109,7 +109,7 @@ var renderBlock = function(block, in_tight_list) {
     case 'CodeBlock':
         info_words = block.info ? block.info.split(/ +/) : [];
         attr = (info_words.length === 0 || info_words[0].length === 0) ?
-            [] : [['class','language-' + this.escape(info_words[0],true)]];
+            [] : [['class', 'language-' + this.escape(info_words[0], true)]];
         return inTags('pre', [],
                       inTags('code', attr, this.escape(block.string_content)));
     case 'HtmlBlock':
@@ -117,7 +117,7 @@ var renderBlock = function(block, in_tight_list) {
     case 'ReferenceDef':
         return "";
     case 'HorizontalRule':
-        return inTags('hr',[],"",true);
+        return inTags('hr', [], "", true);
     default:
         console.log("Unknown block type " + block.t);
         return "";
@@ -127,7 +127,7 @@ var renderBlock = function(block, in_tight_list) {
 // Render a list of block elements, separated by this.blocksep.
 var renderBlocks = function(blocks, in_tight_list) {
     var result = [];
-    for (var i=0; i < blocks.length; i++) {
+    for (var i = 0; i < blocks.length; i++) {
         if (blocks[i].t !== 'ReferenceDef') {
             result.push(this.renderBlock(blocks[i], in_tight_list));
         }
diff --git a/js/lib/inlines.js b/js/lib/inlines.js
@@ -509,7 +509,7 @@ var parseCloseBracket = function(inlines) {
     var link_text;
     var i;
     var reflabel;
-    var opener, closer_above, tempstack;
+    var opener, closer_above;
 
     this.pos += 1;
     startpos = this.pos;
@@ -676,7 +676,6 @@ var parseReference = function(s, refmap) {
     var title;
     var matchChars;
     var startpos = this.pos;
-    var m;
 
     // label:
     matchChars = this.parseLinkLabel();