mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-18 13:39:31 +02:00
Merge pull request #8 from iib0011/string-join
Fix checkboxes in join string
This commit is contained in:
0
src/components/ToolsExamples.tsx
Normal file
0
src/components/ToolsExamples.tsx
Normal 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`;
|
||||
|
Reference in New Issue
Block a user