Permalink
Browse files

Writer.breakLine infinite loop. Closes #27.

  • Loading branch information...
1 parent d20bacc commit 15b2372f789b4008337b3ec8abe40c443b8802b1 @donpark committed Dec 3, 2011
Showing with 168 additions and 188 deletions.
  1. +16 −17 lib/html2jade.coffee
  2. +149 −170 lib/html2jade.js
  3. +1 −1 package.json
  4. +2 −0 test/data/textarea-javascript.html
View
@@ -97,24 +97,23 @@ class Writer
@writeTextLine line, output, pipe, trim, wrap
breakLine: (line) ->
- if line and line.length > 0
- lines = []
- words = line.split(/\s+/)
- line = ''
- while words.length
- word = words.shift()
- if line.length + word.length > @wrapLength
- lines.push line
- line = word
- else if line.length
- line += ' ' + word
- else
- line = word
- if line.length
+ return [] if not line or line.length is 0
+ return [ line ] if line.search /\s+/ is -1
+ lines = []
+ words = line.split(/\s+/)
+ line = ''
+ while words.length
+ word = words.shift()
+ if line.length + word.length > @wrapLength
lines.push line
- lines
- else
- []
+ line = word
+ else if line.length
+ line += ' ' + word
+ else
+ line = word
+ if line.length
+ lines.push line
+ lines
publicIdDocTypeNames =
Oops, something went wrong.

0 comments on commit 15b2372

Please sign in to comment.