Merge pull request #8 from iib0011/string-join

Fix checkboxes in join string
This commit is contained in:
Made4Uo 2024-06-23 15:49:40 -07:00 committed by GitHub
commit 614b10e9d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

View file

@ -5,13 +5,23 @@ export function mergeText(
joinCharacter: string = ''
): string {
let processedLines: string[] = text.split('\n');
if (deleteTrailingSpaces) {
processedLines = processedLines.map((line) => line.trimEnd());
}
if (deleteBlankLines) {
processedLines = processedLines.filter((line) => line.trim());
processedLines = processedLines.filter((line) => line.trim() !== '');
} else {
processedLines = processedLines.map((line) =>
line.trim() === '' ? line + '\r\n\n' : line
);
}
return processedLines.join(joinCharacter);
}
// Example text to use
`This is a line with trailing spaces
Another line with trailing spaces
Final line without trailing spaces`;