Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug in wordwrapping

commit 18f954439f81470a52e6764d29ffe33cb1cf2652 1 parent 940839e
Brenton Fletcher authored
Showing with 4 additions and 6 deletions.
  1. +4 −6 scripts/parse.js
View
10 scripts/parse.js
@@ -19,6 +19,7 @@ function escapeHTML(str)
function wordwrap(str)
{
parts = str.split(" ");
+
for(i = 0; i < parts.length; i++)
{
if(parts[i].length <= 30) continue;
@@ -26,13 +27,10 @@ function wordwrap(str)
t = parts[i].length;
p = "";
- while(t > 30)
- {
- p += parts[i].substr(t - 30, t) + "<wbr />";
- t -= 30;
- }
- parts[i] = p;
+ for(var j = 0; j < (parts[i].length - 30); j += 30) p += parts[i].substring(j, j + 30) + "<wbr />";
+ parts[i] = p + parts[i].substring(j, parts[i].length);
}
+
return parts.join(" ");
}
Please sign in to comment.
Something went wrong with that request. Please try again.