Nodes/yanhuo-easy-use/文本处理
ComfyUI Node

文本处理

Turn one wall of text into paragraphs you can wire one by one

By yanhuoxunxianren·Created 27 days ago·Updated 21 days ago· 2
文本处理
  • any_1
  • any_2
  • any_3
  • any_4
  • any_5
  • any_6
  • any_7
  • any_8
  • any_9
  • any_10
  • any_11
  • any_12
  • any_13
  • any_14
  • any_15
  • any_16
  • any_17
  • any_18
  • any_19
  • any_20
  • any_21
  • any_22
  • any_23
  • any_24
  • any_25
  • any_26
  • any_27
  • any_28
  • any_29
  • any_30
  • any_31
  • any_32
  • any_33
  • any_34
  • any_35
  • any_36
  • any_37
  • any_38
  • any_39
  • any_40
  • any_41
  • any_42
  • any_43
  • any_44
  • any_45
  • any_46
  • any_47
  • any_48
  • any_49
  • any_50
  • any_51
  • any_52
  • any_53
  • any_54
  • any_55
  • any_56
  • any_57
  • any_58
  • any_59
  • any_60
  • any_61
  • any_62
  • any_63
  • any_64
  • 数:
  • 总段:
  • 段落1
  • 段落2
  • 段落3
  • 段落4
  • 段落5
  • 段落6
  • 段落7
  • 段落8
  • 段落9
  • 段落10
  • 段落11
  • 段落12
  • 段落13
  • 段落14
  • 段落15
  • 段落16
  • 段落17
  • 段落18
  • 段落19
  • 段落20
  • 段落21
  • 段落22
  • 段落23
  • 段落24
  • 段落25
  • 段落26
  • 段落27
  • 段落28
  • 段落29
  • 段落30
  • 段落31
  • 段落32
  • 段落33
  • 段落34
  • 段落35
  • 段落36
  • 段落37
  • 段落38
  • 段落39
  • 段落40
  • 段落41
  • 段落42
  • 段落43
  • 段落44
  • 段落45
  • 段落46
  • 段落47
  • 段落48
  • 段落49
  • 段落50
  • 段落51
  • 段落52
  • 段落53
  • 段落54
  • 段落55
  • 段落56
  • 段落57
  • 段落58
  • 段落59
  • 段落60
  • 段落61
  • 段落62
  • 段落63
  • 段落64
  • 段落65
  • 段落66
  • 段落67
  • 段落68
  • 段落69
  • 段落70
  • 段落71
  • 段落72
  • 段落73
  • 段落74
  • 段落75
  • 段落76
  • 段落77
  • 段落78
  • 段落79
  • 段落80
  • 段落81
  • 段落82
  • 段落83
  • 段落84
  • 段落85
  • 段落86
  • 段落87
  • 段落88
  • 段落89
  • 段落90
  • 段落91
  • 段落92
  • 段落93
  • 段落94
  • 段落95
  • 段落96
  • 段落97
  • 段落98
  • 段落99
  • 段落100
◄text—►
◄输出模式false►
◄段落优化true►
◄分段方式空行►
◄输出段落0►
◄输入端口1►
◄选取段落-1►

This is the biggest node in the pack and the one that's hardest to explain in a sentence, because it's really three nodes in a trench coat: a joiner, a splitter, and a selector. You feed it text (from the text box, or from up to 64 other nodes), tell it how to cut the result up, and then choose which pieces come out on which port.

If you've ever pasted a multi-line script into a prompt field and thought "I want each of these to be its own branch," this is the node for that.

Joining: 64 wildcard inputs

text is the base text box. On top of that, any_1 through any_64 accept anything - text, numbers, lists, which get stringified on the way in (lists join by newline, bytes decode as UTF-8). 输入端口 sets how many of those ports exist, and you have to click 更新端口 on the node for the change to take effect.

When you've connected any of them, the port contents are joined with triple newlines and replace the base text. When you haven't, the base text is used as-is. Order is port order, which is what makes this the standard way to concatenate three text sources from three different places into one paste-able block.

Splitting: eight modes

分段方式 is where the personality is:

  • 空行 (default) - splits on double newlines and rejoins within a paragraph. The natural mode for pasted prose.
  • 端口 - one paragraph per input port, strictly by port index. With a gap in the middle you get an empty paragraph in that position rather than a shift, which is deliberate: 段落2 always means port 2.
  • 序号 - starts a new paragraph at a list marker. The regex is broader than the READMEs usually admit: 1. style counters, bracketed forms like (1), roman numerals, Chinese numerals, and bullet glyphs all count as markers.
  • 段落 - every line is its own paragraph. Blunt and predictable, and what you want for line-per-prompt text.
  • 标题 - heuristic chapter detection. Short lines (20 characters or fewer, after trimming) that don't end in punctuation get treated as headings; a run of headings accumulates into the block that follows. Works nicely on a structured document, produces nonsense on a casual one.
  • 数字 - keep only the numbers. Genuinely useful as a parser for "extract every numeric value from this pile of text," and great for grabbing values out of a filename dump or a parameter listing.
  • 地址 - extracts Windows paths (D:\Data\img.png) out of messy strings, including Python-object reprs. That's exactly what it's for: recovering file paths from text that was never meant to be read by a human, ready for 加载批量图像's track JSON or a save-prefix field.
  • 手动 - you insert ||| where the cuts go.

段落优化 toggles whitespace hygiene: on (default) trims each line and joins paragraphs with spaces, off preserves the original indentation and line structure. If you're splitting markdown or code, turn it off.

Selecting: which paragraphs come out where

选取段落 takes -1 for everything, empty for nothing, or indexes like 0,2,4 for paragraphs 1, 3 and 5 - and it does not have to be comma-separated: full-width commas, 、, dots and slashes are all accepted as separators.

Two outputs matter, plus the giant bank of per-paragraph ports:

  • 数: - an INT with the count of selected paragraphs. Great for driving a loop-ish section of a graph or for sanity-checking your split without previewing anything.
  • 总段: - a STRING list of the selected paragraphs. This is the one you usually wire into something downstream.
  • 段落1 … 段落100 - individual STRING outputs, generated by setting 输出段落 (click 更新端口 again) and then wiring each one wherever it belongs.

There's one nuance that follows from the author's design rather than conventional expectations: in 分段列表 mode, the 段落x ports stay aligned to the original paragraph index - select paragraph index 2 and it appears on 段落3, with 段落1 and 段落2 empty. Switch 输出模式 off (输出原始文本) and the selected paragraphs instead collapse into one joined string that lands on 段落1. Which means 段落x port alignment changes meaning when you flip 输出模式. Know which mode you're in before you wire a dozen ports.

Install

yanhuo-easy-use, 16 nodes, category yanhuo, Chinese labels, MIT, v1.3.1. ComfyUI Manager → search the pack title → install → restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanhuoxunxianren/yanhuo-easy-use
# restart ComfyUI

No pip install - pyproject.toml declares no dependencies - and no model downloads. It's a string node; it works with no GPU at all. The 64 input and 100 output ports exist in the class definition already, so expanding the port counts doesn't need another file write; it's the frontend that adds the sockets.

Common issues

"My new ports didn't appear." Change 输入端口 or 输出段落, then click 更新端口. The number alone does nothing.

"Everything came out on 段落1." You're in 输出原始文本 mode, where selected paragraphs are joined into the first port. Flip 输出模式 on for per-paragraph output.

"The split landed in the wrong place." The default 空行 mode wants a blank line between paragraphs. Single newlines don't count - that's what 段落 mode is for. And 标题 is a heuristic; if it misfires, you're asking it to guess.

"A whole paragraph vanished." Check 选取段落. A leftover 0,1,2 from a previous experiment silently drops everything else, and that's the most common version of this complaint.

"The node returned nothing at all." Empty input returns zeroes and empty strings rather than erroring, so an empty result usually means the upstream text node produced nothing - or 选取段落 was left blank, which means "select nothing" by design.

Categoryyanhuo

Inputs (71)

NameTypeDefaultDescription
textSTRING基础文本输入框。 如果您使用[输入端口]功能连接了其他节点,此处的文本将作为第1部分,其他端口(any_xx)的内容会按顺序拼接在其后。
输出模式BOOLEANfalse控制端口输出的内容: ● 输出原始文本(执行分段方式、段落优化、选取段落等所有处理规则,最终合并为一段文本输出)。 ● 输出分段列表(输出分割处理后的内容,按分段方式进行分割,以列表形式输出)。
段落优化BOOLEANtrue优化文本空格 ● 去除首尾空格(自动删除首尾空格、换行符。无论输出原文还是分段均有效)。 ● 保留原始空格(完全保留原始文本的格式和缩进)。
分段方式COMBO空行【核心分割逻辑】 ● 端口:严格按输入端口(any_x)分割。 ● 空行:识别双换行符。 ● 序号:识别 1. / (1) / A. 等列表标记。 ● 段落:每一行算一段。 ● 标题:智能识别章节标题。 ● 数字:仅提取纯数字。 ● 地址:智能从乱码、列表、对象字符串中提取 Windows 文件路径 (如 D:\Data\img.png),并自动清洗格式。 ● 手动:识别 ||| 分隔符进行自定义分割。
输出段落INT0【动态扩展输出】 设置节点右侧[段落x]输出端口的数量。 例如设为 3,右侧会出现 段落1, 段落2, 段落3。 (需点击节点上的「更新端口」按钮生效)
输入端口INT1【动态扩展输入】 设置节点左侧[any_x]输入端口的数量。 用于将多个文本源(如多个加载文本节点)按顺序拼合在一起进行统一分段处理。 (注意:修改数值后需点击节点上的「更新端口」按钮生效)
选取段落STRING-1【分割后段落选取】 决定选取哪些段落输出。 ● -1(默认):输出所有段落。 ● 留空:不选取任何段落,总段输出为空。 ● 0 为第一段、1 为第二段,以此类推。 ● 输入 0,2,4:输出第1、3、5段,丢弃其他。 此设置会改变[总段]和[段落x]端口的内容。
any_1opt*—
any_2opt*—
any_3opt*—
any_4opt*—
any_5opt*—
any_6opt*—
any_7opt*—
any_8opt*—
any_9opt*—
any_10opt*—
any_11opt*—
any_12opt*—
any_13opt*—
any_14opt*—
any_15opt*—
any_16opt*—
any_17opt*—
any_18opt*—
any_19opt*—
any_20opt*—
any_21opt*—
any_22opt*—
any_23opt*—
any_24opt*—
any_25opt*—
any_26opt*—
any_27opt*—
any_28opt*—
any_29opt*—
any_30opt*—
any_31opt*—
any_32opt*—
any_33opt*—
any_34opt*—
any_35opt*—
any_36opt*—
any_37opt*—
any_38opt*—
any_39opt*—
any_40opt*—
any_41opt*—
any_42opt*—
any_43opt*—
any_44opt*—
any_45opt*—
any_46opt*—
any_47opt*—
any_48opt*—
any_49opt*—
any_50opt*—
any_51opt*—
any_52opt*—
any_53opt*—
any_54opt*—
any_55opt*—
any_56opt*—
any_57opt*—
any_58opt*—
any_59opt*—
any_60opt*—
any_61opt*—
any_62opt*—
any_63opt*—
any_64opt*—

Outputs (102)

NameTypeDescription
数:INT—
总段:STRING—
段落1STRING—
段落2STRING—
段落3STRING—
段落4STRING—
段落5STRING—
段落6STRING—
段落7STRING—
段落8STRING—
段落9STRING—
段落10STRING—
段落11STRING—
段落12STRING—
段落13STRING—
段落14STRING—
段落15STRING—
段落16STRING—
段落17STRING—
段落18STRING—
段落19STRING—
段落20STRING—
段落21STRING—
段落22STRING—
段落23STRING—
段落24STRING—
段落25STRING—
段落26STRING—
段落27STRING—
段落28STRING—
段落29STRING—
段落30STRING—
段落31STRING—
段落32STRING—
段落33STRING—
段落34STRING—
段落35STRING—
段落36STRING—
段落37STRING—
段落38STRING—
段落39STRING—
段落40STRING—
段落41STRING—
段落42STRING—
段落43STRING—
段落44STRING—
段落45STRING—
段落46STRING—
段落47STRING—
段落48STRING—
段落49STRING—
段落50STRING—
段落51STRING—
段落52STRING—
段落53STRING—
段落54STRING—
段落55STRING—
段落56STRING—
段落57STRING—
段落58STRING—
段落59STRING—
段落60STRING—
段落61STRING—
段落62STRING—
段落63STRING—
段落64STRING—
段落65STRING—
段落66STRING—
段落67STRING—
段落68STRING—
段落69STRING—
段落70STRING—
段落71STRING—
段落72STRING—
段落73STRING—
段落74STRING—
段落75STRING—
段落76STRING—
段落77STRING—
段落78STRING—
段落79STRING—
段落80STRING—
段落81STRING—
段落82STRING—
段落83STRING—
段落84STRING—
段落85STRING—
段落86STRING—
段落87STRING—
段落88STRING—
段落89STRING—
段落90STRING—
段落91STRING—
段落92STRING—
段落93STRING—
段落94STRING—
段落95STRING—
段落96STRING—
段落97STRING—
段落98STRING—
段落99STRING—
段落100STRING—