Skip to content

Commit 3e360c1

Browse files
committed
Enhance RemoveTextBetween node to return removed text; Fix for wrap_text
1 parent e4866f0 commit 3e360c1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mikey_nodes.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,6 +3710,7 @@ def wrap_text(self, text, font, max_width):
37103710
wrapped_lines.append(new_line)
37113711
new_line = word
37123712
wrapped_lines.append(new_line)
3713+
wrapped_lines.append("")
37133714
return wrapped_lines
37143715

37153716
@apply_to_batch
@@ -4187,15 +4188,21 @@ def INPUT_TYPES(cls):
41874188
'optional': {'start': ('STRING', {'default': '<think>'}),
41884189
'end': ('STRING', {'default': '</think>'})}}
41894190

4190-
RETURN_TYPES = ('STRING',)
4191+
RETURN_TYPES = ('STRING','STRING')
4192+
RETURN_NAMES = ('text','removed_text')
41914193
FUNCTION = 'remove'
41924194
CATEGORY = 'Mikey/Text'
41934195

41944196
def remove(self, text, start, end):
41954197
# search and replace
41964198
# remove text between start and end
4199+
removed = re.findall(re.escape(start) + '(.*?)' + re.escape(end), text, flags=re.DOTALL)
41974200
text = re.sub(re.escape(start) + '.*?' + re.escape(end), '', text, flags=re.DOTALL).lstrip().rstrip()
4198-
return (text,)
4201+
if len(removed) == 1:
4202+
removed_text = removed[0].lstrip().rstrip()
4203+
else:
4204+
removed_text = '\n'.join(removed)
4205+
return (text, removed_text)
41994206

42004207
class OobaPrompt:
42014208
@classmethod

0 commit comments

Comments
 (0)