cmark

My personal build of CMark ✏️

Commit
031a126b86c82fab47b5d87e34da31a7657a55d1
Parent
9bf2a0b1bcaff8f6c00d68cf40a99e4adebcb99b
Author
John MacFarlane <fiddlosopher@gmail.com>
Date

JS: Improved end lines.

Closes #276.

Diffstat

1 file changed, 4 insertions, 8 deletions

Status File Name N° Changes Insertions Deletions
Modified js/lib/blocks.js 12 4 8
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
@@ -132,7 +132,7 @@ var addLine = function(ln, offset) {
 var addChild = function(tag, line_number, offset) {
     "use strict";
     while (!canContain(this.tip.t, tag)) {
-        this.finalize(this.tip, line_number);
+        this.finalize(this.tip, line_number - 1);
     }
 
     var column_number = offset + 1; // offset 0 = column 1
@@ -322,7 +322,7 @@ var incorporateLine = function(ln, line_number) {
         var already_done = false;
         // finalize any blocks not matched
         while (!already_done && oldtip !== last_matched_container) {
-            mythis.finalize(oldtip, line_number);
+            mythis.finalize(oldtip, line_number - 1);
             oldtip = oldtip.parent;
         }
         already_done = true;
@@ -547,11 +547,7 @@ var finalize = function(block, line_number) {
         return 0;
     }
     block.open = false;
-    if (line_number > block.pos.start[0]) {
-        block.pos.end = [line_number - 1]; // TODO end column
-    } else {
-        block.pos.end = [line_number];
-    }
+    block.pos.end = [line_number]; // TODO end column
 
     switch (block.t) {
     case 'Paragraph':
@@ -659,7 +655,7 @@ var parse = function(input) {
         this.incorporateLine(lines[i], i + 1);
     }
     while (this.tip) {
-        this.finalize(this.tip, len - 1);
+        this.finalize(this.tip, len);
     }
     this.processInlines(this.doc);
     return this.doc;