cmark

My personal build of CMark ✏️

Commit
b6f684b615507fda3340f78f797056beb803f5cb
Parent
200ef0233777cbe0d2deefc3365d4f563d31828c
Author
John MacFarlane <jgm@berkeley.edu>
Date

More HTML rendering efficiency improvements.

Diffstat

1 file changed, 5 insertions, 2 deletions

Status File Name N° Changes Insertions Deletions
Modified js/lib/html.js 7 5 2
diff --git a/js/lib/html.js b/js/lib/html.js
@@ -27,6 +27,7 @@ var renderNodes = function(block, options) {
     var walker = block.walker();
     var event, node, entering;
     var buffer = "";
+    var lastOut = "\n";
     var disableTags = 0;
     var grandparent;
     var out = function(s) {
@@ -35,11 +36,13 @@ var renderNodes = function(block, options) {
         } else {
             buffer += s;
         }
+        lastOut = s;
     };
     var esc = this.escape;
     var cr = function() {
-        if (buffer.length > 0 && buffer.charAt[buffer.length - 1] !== '\n') {
-            out('\n');
+        if (lastOut !== '\n') {
+            buffer += '\n';
+            lastOut = '\n';
         }
     };