Upstream spencermountain/compromise state of the touched files before 1c69df46a3

This commit is contained in:
upstream committed 2026-10-03 03:09:19 +02:00
1 parent cab0138668
commit a85b530171
2 files changed
+113

No files matched your search

@@ -0,0 +1,25 @@
const hasDash = /[a-z0-9][-–—][a-z]/i
// match 're-do' -> ['re','do']
const splitHyphens = function (regs, world) {
const prefixes = world.model.one.prefixes
for (let i = regs.length - 1; i >= 0; i -= 1) {
const reg = regs[i]
if (reg.word && hasDash.test(reg.word)) {
let words = reg.word.split(/[-–—]/g)
// don't split 're-cycle', etc
if (Object.hasOwn(prefixes, words[0])) {
continue
}
words = words.filter(w => w).reverse()
regs.splice(i, 1)
words.forEach(w => {
const obj = { ...reg }
obj.word = w
regs.splice(i, 0, obj)
})
}
}
return regs
}
export default splitHyphens