CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-wrap-ansi

Wordwrap a string with ANSI escape codes

Overall
score

100%

Overview
Eval results
Files

task.mdevals/scenario-4/

Styled Terminal Link Wrapper

A utility for wrapping text containing styled hyperlinks to fit within terminal column constraints.

Capabilities

Wraps text with styled hyperlinks

  • Given text containing a clickable hyperlink with colored text inside it, wrap the text to 20 columns and verify the output maintains both the hyperlink and color formatting across line breaks @test
  • Given text with a hyperlink containing bold styled text, wrap to 15 columns and verify bold styling is preserved when the link spans multiple lines @test

Handles complex nested formatting

  • Given text with a hyperlink containing multiple different ANSI color codes (e.g., red and blue text within the same link), wrap to 25 columns and verify all color codes are correctly maintained @test
  • Given a hyperlink with nested styling (both color and text decoration like underline), wrap to 18 columns and ensure both style types persist across wrapped lines @test

Implementation

@generates

API

/**
 * Wraps text containing styled hyperlinks to fit within a specified column width.
 * Preserves ANSI escape codes for both hyperlinks and text styling (colors, bold, etc.)
 * across line breaks.
 *
 * @param {string} text - The text to wrap, may contain ANSI hyperlinks and style codes
 * @param {number} columns - The maximum column width for wrapping
 * @returns {string} The wrapped text with preserved formatting
 */
function wrapStyledLinks(text, columns) {
  // IMPLEMENTATION HERE
}

module.exports = { wrapStyledLinks };

Dependencies { .dependencies }

wrap-ansi { .dependency }

Provides text wrapping with ANSI escape code preservation, including support for hyperlinks and nested styling.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-wrap-ansi

tile.json