|
|
@@ -3,13 +3,21 @@ define [
|
|
|
], (App) ->
|
|
|
DEF_MIN_LENGTH = 20
|
|
|
|
|
|
+ _decodeHTMLEntities = (str) ->
|
|
|
+ str.replace /&#(\d+);/g, (match, dec) ->
|
|
|
+ String.fromCharCode dec;
|
|
|
+
|
|
|
_getWrappedWordsString = (baseStr, wrapperElName, minLength) ->
|
|
|
minLength = minLength || DEF_MIN_LENGTH
|
|
|
+ words = baseStr.split ' '
|
|
|
|
|
|
- findWordsRegEx = new RegExp "\\w{#{minLength},}", "g"
|
|
|
- wrappingTemplate = "<#{wrapperElName} class=\"break-word\">$&</#{wrapperElName}>"
|
|
|
+ wordsWrapped = for word in words
|
|
|
+ if _decodeHTMLEntities(word).length >= minLength
|
|
|
+ "<#{wrapperElName} class=\"break-word\">#{word}</#{wrapperElName}>"
|
|
|
+ else
|
|
|
+ word
|
|
|
|
|
|
- baseStr.replace findWordsRegEx, wrappingTemplate
|
|
|
+ outputStr = wordsWrapped.join ' '
|
|
|
|
|
|
|
|
|
App.filter "wrapLongWords", () ->
|