Skip to main content
Version: 1.3.0

Text Wrap

Text Processing Formatting

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:

FieldRequiredDefaultDescription
fieldY-Source field containing text to wrap
widthY-Maximum line width in characters
break_on_wordsNtrueBreak at word boundaries instead of character boundaries
target_fieldNSame as fieldTarget field to store wrapped text
indentN-String to indent each line (e.g., " " for spaces)
break_characterN\nCharacter to use for line breaks
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if wrapping fails
ignore_missingNfalseSkip processing if referenced field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-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.

note

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.

warning

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...

{
"description": "This is a very long description that needs to be formatted for better readability in documentation or display purposes."
}
- text_wrap:
field: description
width: 40
target_field: formatted_text

creates formatted multi-line text:

{
"description": "This is a very long description...",
"formatted_text": "This is a very long description that\nneeds to be formatted for better\nreadability in documentation or display\npurposes."
}

Code Comment Formatting

Formatting code comments with indentation...

{
"comment": "This function processes user authentication requests and validates credentials against the database before returning access tokens."
}
- text_wrap:
field: comment
width: 50
indent: "// "
target_field: code_comment

creates indented code comments:

{
"comment": "This function processes user authentication...",
"code_comment": "// This function processes user authentication\n// requests and validates credentials against the\n// database before returning access tokens."
}

Fixed-width Formatting

Creating fixed-width text without word breaks...

{
"log_message": "SystemStartupInitializationCompleted"
}
- text_wrap:
field: log_message
width: 15
break_on_words: false
target_field: wrapped_log

breaks at exact character positions:

{
"log_message": "SystemStartupInitializationCompleted",
"wrapped_log": "SystemStartupIn\nitializationCo\nmpleted"
}

Custom Line Breaks

Using custom line break characters...

{
"tags": "authentication authorization logging monitoring security audit compliance"
}
- text_wrap:
field: tags
width: 20
break_character: " | "
target_field: tag_list

uses custom separator:

{
"tags": "authentication authorization logging monitoring security audit compliance",
"tag_list": "authentication | authorization logging | monitoring security | audit compliance"
}

Email Formatting

Formatting email content with line length limits...

{
"email_body": "Dear customer, we are writing to inform you about important changes to our service terms and conditions that will take effect next month."
}
- text_wrap:
field: email_body
width: 72
target_field: formatted_email

formats for email standards:

{
"email_body": "Dear customer, we are writing to inform you about important...",
"formatted_email": "Dear customer, we are writing to inform you about important changes\nto our service terms and conditions that will take effect next month."
}