mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 12:04:46 +00:00
Use string split instead of regex.
This commit is contained in:
parent
ff62e50530
commit
01637386bd
2 changed files with 11 additions and 4 deletions
|
@ -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", () ->
|
||||
|
|
|
@ -131,7 +131,6 @@
|
|||
|
||||
.break-word {
|
||||
word-break: break-all;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.editor-dark {
|
||||
|
|
Loading…
Add table
Reference in a new issue