Recortar texto
text-truncateAcorta texto a un máximo de caracteres (grafemas) o palabras, con puntos suspensivos. Cuándo: hay que transformar, comparar o medir un texto con exactitud y no por aproximación. No para: ajustar texto a un ancho máximo de línea respetando saltos existentes (text-wrap). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.
EN: Shortens text to a maximum number of graphemes or words, optionally at a word boundary, appending an ellipsis that counts toward the limit. When: text has to be transformed, compared or measured exactly instead of approximated. Not for: wrapping text to a maximum line width (text-wrap). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max | Yes | Maximum length (integer; required; min 1; max 100000). | |
| text | Yes | Input text (string; required). | |
| unit | No | Unit (optional; one of: graphemes, words; default "graphemes"). | graphemes |
| ellipsis | No | Suffix when truncated (string; optional; default "…"; up to 10 chars). | … |
| word_boundary | No | Cut at word boundary (graphemes mode) (boolean; optional; default true). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | ||
| truncated | No |