Skip to content

Commit

Permalink
Make sure tags are closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjatse committed Dec 16, 2014
1 parent 7689fe8 commit 16af51a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function ansiHTML(text){
// Cache opened sequence.
var ansiCodes = [];
// Replace with markup.
return text.replace(/\033\[(\d+)*m/g, function(match, seq){
var ret = text.replace(/\033\[(\d+)*m/g, function(match, seq){
var ot = openTags[seq];
if (ot) {
// If current sequence has been opened, close it.
Expand All @@ -79,6 +79,12 @@ function ansiHTML(text){
}
return '';
});

// Make sure tags are closed.
var l = ansiCodes.length;
(l > 0) && (ret += Array(l + 1).join('</span>'));

return ret;
}

/**
Expand Down

0 comments on commit 16af51a

Please sign in to comment.