Skip to content

Commit 949be06

Browse files
committed
Add separator_escaping to 'String Repeat'
1 parent 360286a commit 949be06

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

node-graph/nodes/gcore/src/logic.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,19 @@ fn string_repeat(
227227
#[min(1)]
228228
count: u32,
229229
/// The string placed between each repetition.
230+
#[default("\\n")]
230231
separator: String,
232+
/// Whether to convert escape sequences found in the separator into their corresponding characters:
233+
/// "\n" (newline), "\r" (carriage return), "\t" (tab), "\0" (null), and "\\" (backslash).
234+
#[default(true)]
235+
separator_escaping: bool,
231236
) -> String {
237+
let separator = if separator_escaping {
238+
separator.replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t").replace("\\0", "\0").replace("\\\\", "\\")
239+
} else {
240+
separator
241+
};
242+
232243
let count = count.max(1) as usize;
233244

234245
let mut result = String::with_capacity((string.len() + separator.len()) * count);
@@ -355,7 +366,7 @@ fn string_capitalization(
355366
/// Whether to split the string into words and rejoin with the specified joiner.
356367
/// When disabled, the existing separators and word structure are preserved.
357368
use_joiner: bool,
358-
/// The string placed between each word. Common choices: " " (space), "_" (underscore), "-" (hyphen), or "" (none).
369+
/// The string placed between each word.
359370
joiner: String,
360371
) -> String {
361372
// When the joiner is disabled, apply only character-level casing while preserving the string's existing structure

0 commit comments

Comments
 (0)