From 378126e60f9f9858b89c4267bb89efaa51452195 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Jan 2026 12:53:09 +0000 Subject: [PATCH] docs: fix block docs sync for Text Encoder - Move Text Encoder docs from standalone encoder_block.md into text.md (matches CATEGORY_FILE_MAP for TEXT category blocks) - Add Text Encoder to overview table in README.md - Remove orphaned encoder_block.md - Follows exact format expected by generate_block_docs.py --- docs/integrations/README.md | 1 + .../block-integrations/encoder_block.md | 46 ------------------- docs/integrations/block-integrations/text.md | 36 +++++++++++++++ 3 files changed, 37 insertions(+), 46 deletions(-) delete mode 100644 docs/integrations/block-integrations/encoder_block.md diff --git a/docs/integrations/README.md b/docs/integrations/README.md index 192405156c..b91f4e2f14 100644 --- a/docs/integrations/README.md +++ b/docs/integrations/README.md @@ -193,6 +193,7 @@ Below is a comprehensive list of all available blocks, categorized by their prim | [Get Current Time](block-integrations/text.md#get-current-time) | This block outputs the current time | | [Match Text Pattern](block-integrations/text.md#match-text-pattern) | Matches text against a regex pattern and forwards data to positive or negative output based on the match | | [Text Decoder](block-integrations/text.md#text-decoder) | Decodes a string containing escape sequences into actual text | +| [Text Encoder](block-integrations/text.md#text-encoder) | Encodes a string by converting special characters into escape sequences | | [Text Replace](block-integrations/text.md#text-replace) | This block is used to replace a text with a new text | | [Text Split](block-integrations/text.md#text-split) | This block is used to split a text into a list of strings | | [Word Character Count](block-integrations/text.md#word-character-count) | Counts the number of words and characters in a given text | diff --git a/docs/integrations/block-integrations/encoder_block.md b/docs/integrations/block-integrations/encoder_block.md deleted file mode 100644 index bcab3083a7..0000000000 --- a/docs/integrations/block-integrations/encoder_block.md +++ /dev/null @@ -1,46 +0,0 @@ -# Text Encoder - -## What it is -A tool that converts text containing special characters into escaped text sequences. - -## What it does -It takes a string of text that contains special characters (like new lines or quotation marks) and converts them into their escape sequence representations (like '\n' for new lines). - -## How it works -The Text Encoder takes the input string and applies Python's `unicode_escape` encoding (equivalent to `codecs.encode(text, "unicode_escape").decode("utf-8")`) to transform special characters like newlines, tabs, and backslashes into their escaped forms. - -The block relies on the input schema to ensure the value is a string; non-string inputs are rejected by validation, and any encoding failures surface as block errors. Non-ASCII characters are emitted as `\uXXXX` sequences, which is useful for ASCII-only payloads. - -## Inputs - -| Input | Description | -|-------|-------------| -| Text | The text you want to encode, which may contain special characters like new lines or quotation marks | - -## Outputs - -| Output | Description | -|--------|-------------| -| Encoded Text | The text after processing, with all special characters converted to their escape sequences | - -## Use Case -- **JSON payload preparation:** Encode multiline or quoted text before embedding it in JSON string fields. -- **Config/ENV generation:** Convert template text into escaped strings for `.env` or YAML values. -- **Snapshot fixtures:** Produce stable escaped strings for golden files or API tests. - -## Example -Imagine you have a piece of text with line breaks that you need to store in a JSON file or send through an API: - -```text -Hello -World! -This is a "quoted" string. -``` - -The Text Encoder can convert it into: - -```text -Hello\nWorld!\nThis is a "quoted" string. -``` - -This is useful when you need to prepare text for storage in formats that require escape sequences, or when sending data to systems that expect encoded text. It's the inverse operation of the Text Decoder block. diff --git a/docs/integrations/block-integrations/text.md b/docs/integrations/block-integrations/text.md index e47375196c..3e760401b9 100644 --- a/docs/integrations/block-integrations/text.md +++ b/docs/integrations/block-integrations/text.md @@ -380,6 +380,42 @@ This is useful when working with data from APIs or files where escape sequences --- +## Text Encoder + +### What it is +Encodes a string by converting special characters into escape sequences + +### How it works + +The Text Encoder takes the input string and applies Python's `unicode_escape` encoding (equivalent to `codecs.encode(text, "unicode_escape").decode("utf-8")`) to transform special characters like newlines, tabs, and backslashes into their escaped forms. + +The block relies on the input schema to ensure the value is a string; non-string inputs are rejected by validation, and any encoding failures surface as block errors. Non-ASCII characters are emitted as `\uXXXX` sequences, which is useful for ASCII-only payloads. + + +### Inputs + +| Input | Description | Type | Required | +|-------|-------------|------|----------| +| text | A string containing special characters to be encoded | str | Yes | + +### Outputs + +| Output | Description | Type | +|--------|-------------|------| +| error | Error message if the operation failed | str | +| encoded_text | The encoded text with special characters converted to escape sequences | str | + +### Possible use case + +**JSON Payload Preparation**: Encode multiline or quoted text before embedding it in JSON string fields to ensure proper escaping. + +**Config/ENV Generation**: Convert template text into escaped strings for `.env` or YAML values that require special character handling. + +**Snapshot Fixtures**: Produce stable escaped strings for golden files or API tests where consistent text representation is needed. + + +--- + ## Text Replace ### What it is