diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-10 14:59:48 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-10 14:59:48 -0800 |
commit | b6f684b615507fda3340f78f797056beb803f5cb (patch) | |
tree | b34df8f1587b41075251c431da70e3f0fd6e6faf /js/lib | |
parent | 200ef0233777cbe0d2deefc3365d4f563d31828c (diff) |
More HTML rendering efficiency improvements.
Diffstat (limited to 'js/lib')
-rw-r--r-- | js/lib/html.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/js/lib/html.js b/js/lib/html.js index 5cf3def..37ee903 100644 --- 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'; } }; |