Suzie1 / ComfyUI_Comfyroll_CustomNodes

Custom nodes for SDXL and SD1.5 including Multi-ControlNet, LoRA, Aspect Ratio, Process Switches, and many more nodes.
https://civitai.com/models/183551/comfyui-comfyroll-custom-nodes
630 stars 85 forks source link

Improvement to CR_PromptText #141

Open MokkaBoss1 opened 6 months ago

MokkaBoss1 commented 6 months ago

Hi,

I have a suggestion to make to improve this node. I tested it and it seems to work fine. Basically it lets you put comments into a text box that do not carry forward to the output. Also I removed line breaks

image

The code for this is as follows:

import random import re

class HashText:

def __init__(self):
    pass

@classmethod
def INPUT_TYPES(s):
    return {"required": {
        "prompt": ("STRING", {"default": "prompt", "multiline": True})
    }}

RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("Text",)
FUNCTION = "test"
CATEGORY = "MokkaBoss1"

def test(self, prompt): 
    pattern = r"#(.*?)#"
    clean_text = re.sub(pattern, '', prompt)
    clean_text2 = clean_text.replace("\n", "")
    prompt = clean_text2
    return (prompt, )

NODE_CLASS_MAPPINGS = {"HashText": HashText} NODE_DISPLAY_NAME_MAPPINGS = {"HashText": "HashText"}

MokkaBoss1 commented 6 months ago

just realised you don't need the "import random" that was a cut and paste error