Browse files

Fix bug in wordwrapping

  • Loading branch information...
1 parent 940839e commit 18f954439f81470a52e6764d29ffe33cb1cf2652 Brenton Fletcher committed May 24, 2009
Showing with 4 additions and 6 deletions.
  1. +4 −6 scripts/parse.js
View
10 scripts/parse.js
@@ -19,20 +19,18 @@ function escapeHTML(str)
function wordwrap(str)
{
parts = str.split(" ");
+
for(i = 0; i < parts.length; i++)
{
if(parts[i].length <= 30) continue;
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(" ");
}

0 comments on commit 18f9544

Please sign in to comment.