Normalize Unicode line separators on paste

Google's lyrics box ships U+2028/U+2029 between lines, which a
textarea collapses — verses arrived as one giant line. All line-
separator flavors (CR, CRLF, LS, PS, NEL, VT, FF) normalize to \n,
and the Lyrics/Songwriters/Musixmatch furniture strips with the rest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 12:54:03 -04:00
parent d268755aa1
commit 56ebb2046b
+5 -1
View File
@@ -998,7 +998,9 @@ function extractAZBlock(t){
return block ? block + '\n' : null;
}
function cleanPaste(t){
t = t.replace(/[\u2018\u2019\u02BC]/g, "'")
t = t.replace(/\r\n?/g, '\n')
.replace(/[\u2028\u2029\u0085\u000B\u000C]/g, '\n') // Google's lyrics box
.replace(/[\u2018\u2019\u02BC]/g, "'")
.replace(/[\u201C\u201D]/g, '"')
.replace(/\u00A0/g, ' ');
const extracted = extractLyricBlock(t) || extractAZBlock(t);
@@ -1011,6 +1013,8 @@ function cleanPaste(t){
if(/^Translations$/i.test(s)) return;
if(/^You might also like/i.test(s)) return;
if(/^Source:\s/i.test(s)) return;
if(/^Songwriters?:/i.test(s)) return;
if(/^Musixmatch$/i.test(s)) return;
if(/^\d*\s*Embed$/.test(s)) return;
out.push(l);
});