feat: 🎸 add escape char mode
This commit is contained in:
+30
-3
@@ -188,7 +188,6 @@ class AsyncOutputCallbackNode:
|
||||
return float('nan')
|
||||
|
||||
|
||||
|
||||
class AsyncOutputConvertStringListToStringNode:
|
||||
def __init__(self):
|
||||
pass
|
||||
@@ -198,7 +197,8 @@ class AsyncOutputConvertStringListToStringNode:
|
||||
return {
|
||||
"required": {
|
||||
"input_string_list": ("LIST", { "forceInput": True }),
|
||||
"join_word": ("STRING", { "default": "" })
|
||||
"join_word": ("STRING", { "default": "" }),
|
||||
"is_escape_char": ("BOOLEAN", { "default": False, "tooltip": "if use ascii escape char, must enable" })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,13 +207,40 @@ class AsyncOutputConvertStringListToStringNode:
|
||||
|
||||
CATEGORY = f'{MAIN_CATEGORY}/Utils'
|
||||
FUNCTION = "convert_string_list_to_string"
|
||||
DESCRIPTION = \
|
||||
"""
|
||||
If use `\n` or others escape_char, must enable `is_escape_char`, or not, module will receive `\\n`, that not expected
|
||||
|
||||
support list:
|
||||
- `\n`
|
||||
- `\t`
|
||||
- `\r`
|
||||
- `\'`
|
||||
- `\"`
|
||||
- `\\`
|
||||
"""
|
||||
|
||||
def convert_string_list_to_string(self, input_string_list=[], join_word=""):
|
||||
def convert_string_list_to_string(self, input_string_list=[], join_word="", is_escape_char=False):
|
||||
|
||||
if isinstance(input_string_list, list) == False:
|
||||
raise Exception("ERROR: input_string_list not a list.")
|
||||
|
||||
result = join_word
|
||||
|
||||
if is_escape_char == True:
|
||||
escape_map = {
|
||||
"\\n": "\n",
|
||||
"\\t": "\t",
|
||||
"\\r": "\r",
|
||||
"\\\"": "\"",
|
||||
"\\\'": "\'",
|
||||
"\\\\": "\\"
|
||||
}
|
||||
|
||||
for escaped, real in escape_map.items():
|
||||
result = result.replace(escaped, real)
|
||||
|
||||
|
||||
result = result.join(input_string_list)
|
||||
|
||||
return (result, )
|
||||
|
||||
Reference in New Issue
Block a user