Text Wrap
Synopsis
Wraps text to specified widths by inserting line breaks.
Schema
- text_wrap:
field: <ident>
width: <integer>
break_on_words: <boolean>
target_field: <string>
indent: <string>
break_character: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Source field containing text to wrap |
width | Y | - | Maximum line width in characters |
break_on_words | N | true | Break at word boundaries instead of character boundaries |
target_field | N | Same as field | Target field to store wrapped text |
indent | N | - | String to indent each line (e.g., " " for spaces) |
break_character | N | \n | Character to use for line breaks |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if wrapping fails |
ignore_missing | N | false | Skip processing if referenced field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
Formats text by inserting line breaks at specified intervals to ensure lines don't exceed the maximum width. The processor can break at word boundaries for readability or at exact character positions for fixed-width requirements.
The processor supports various formatting options including custom indentation, line break characters, and word-boundary preservation.
When break_on_words
is enabled (default), the processor avoids breaking words in the middle, which may result in lines shorter than the specified width. When disabled, lines will be exactly the specified width regardless of word boundaries.
The processor handles Unicode characters correctly and counts display width rather than byte length, ensuring proper formatting for international text.
Very long words that exceed the specified width will be broken at character boundaries even when break_on_words
is enabled, to prevent infinite line lengths.
Examples
Basic Text Wrapping
Wrapping long text to 40-character lines... |
|
creates formatted multi-line text: |
|
Code Comment Formatting
Formatting code comments with indentation... |
|
creates indented code comments: |
|
Fixed-width Formatting
Creating fixed-width text without word breaks... |
|
breaks at exact character positions: |
|
Custom Line Breaks
Using custom line break characters... |
|
uses custom separator: |
|
Email Formatting
Formatting email content with line length limits... |
|
formats for email standards: |
|