Initial commit
This commit is contained in:
@@ -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 <your_github_repo_url>
|
||||
```
|
||||
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.
|
||||
+24
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user