You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
smartwrap is not able to break words as well as breakword
I think maybe there is some use of .split() and/or .substr() that needs to be changed to arrays created with the spread operator [...str] which knows how to correctly divide strings to characters
See output from:
const breakword = require("breakword")
const str = "😀😀😀😀"
console.log(`String: ${str}`)
for (let w = 0; w < 10; w++) {
let x = breakword(str,w),
part1 = [...str].slice(0, x + 1).join(""),
part2 = [...str].slice(x + 1).join("")
console.log(`w=${w} bw=${x} "${part1}" "${part2}"`)
}
const smartwrap = require("smartwrap")
console.log(`String: ${str}`)
for (let w = 0; w < 10; w++) {
let wrapped = smartwrap(str, {width: w, breakword: true, errorChar: "é"}),
lines = wrapped.split("\n"),
part1 = lines[0],
part2 = lines[1] || null
console.log(`lines=${lines.length} ${JSON.stringify(part1)} ${JSON.stringify(part2)}`)
}
The text was updated successfully, but these errors were encountered:
smartwrap is not able to break words as well as breakword
I think maybe there is some use of
.split()
and/or.substr()
that needs to be changed to arrays created with the spread operator[...str]
which knows how to correctly divide strings to charactersSee output from:
The text was updated successfully, but these errors were encountered: