add trim sentence feature

This commit is contained in:
Sanskar Tiwari
2023-05-15 19:29:59 +05:30
parent d97058ab89
commit 2f8b95b18d
4 changed files with 49 additions and 2 deletions

View File

@ -188,4 +188,13 @@ export function sortByCssOrder(a, b) {
const _a = Number($(a).css('order'));
const _b = Number($(b).css('order'));
return _a - _b;
}
}
export function end_trim_to_sentence(input, keep_newlines = false) {
if (!keep_newlines) {
return input.trimEnd();
} else {
// trim all whitespace at the end of the string, except for newlines
return input.replace(/([^\S\r\n])+(?=\n*$)/g, "");
}
}