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
This commit is contained in:
root
2026-01-29 12:53:09 +00:00
parent 21a1d993b8
commit 378126e60f
3 changed files with 37 additions and 46 deletions

View File

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

View File

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

View File

@@ -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
<!-- MANUAL: 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.
<!-- END MANUAL -->
### 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
<!-- MANUAL: 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.
<!-- END MANUAL -->
---
## Text Replace
### What it is