From 8d45d0cd1ac85a51101a424cc898d501dc01b376 Mon Sep 17 00:00:00 2001 From: wrt122311 <1720122311@qq.com> Date: Thu, 21 May 2026 00:00:28 +0800 Subject: [PATCH] Initial commit --- README.md | 19 +++++++++++++++++++ __init__.py | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 README.md create mode 100644 __init__.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..186f94b --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# ComfyUI Escape Brackets Node + +A simple custom node for [ComfyUI](https://github.com/comfyanonymous/ComfyUI) that escapes parentheses in strings. + +## Functionality +This node takes a string as input, replaces all occurrences of `(` with `\(` and `)` with `\)`, and outputs the modified string. This is particularly useful when you need to pass text containing brackets to specific prompts or processes that interpret brackets as syntax (e.g., prompt weighting) and you want them to be treated as literal characters. + +## Installation +1. Navigate to your ComfyUI `custom_nodes` directory. +2. Clone this repository into it: + ```bash + git clone + ``` +3. Restart ComfyUI. + +## Usage +- You can find the node under the **text** category, named **Escape Brackets Node**. +- Connect a string to the `text` input. +- Connect the `STRING` output to whatever node requires the escaped text. diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..50b0bca --- /dev/null +++ b/__init__.py @@ -0,0 +1,24 @@ +class EscapeBracketsNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "text": ("STRING", {"multiline": True}), + }, + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "escape_text" + CATEGORY = "text" + + def escape_text(self, text): + escaped_text = text.replace("(", "\\(").replace(")", "\\)") + return (escaped_text,) + +NODE_CLASS_MAPPINGS = { + "EscapeBracketsNode": EscapeBracketsNode +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "EscapeBracketsNode": "Escape Brackets Node" +}