Module: Terminal::Table::Util

Defined in:
lib/kramdown/ansi.rb

Overview

A utility module that provides ANSI escape sequence removal functionality for terminal table content.

The Terminal::Table::Util module contains helper methods for processing text that may contain ANSI escape sequences, particularly for cleaning up terminal table output before further processing or display.

Examples:

Removing ANSI escape sequences from table lines

cleaned_line = Terminal::Table::Util.ansi_escape("\e[1mBold Text\e[0m")

Class Method Summary collapse

Class Method Details

.ansi_escape(line) ⇒ String

Removes ANSI escape sequences from the given line of text.

This method strips out all ANSI escape codes that are commonly used to format terminal output with colors, styles, and cursor movements.

sequences sequences removed

Parameters:

  • line (String)

    the input string that may contain ANSI escape

Returns:

  • (String)

    a copy of the input string with all ANSI escape



58
59
60
# File 'lib/kramdown/ansi.rb', line 58

def self.ansi_escape(line)
  line.to_s.gsub(/\e\[.*?m|\e\].*?(\e|\a)\\?/, '')
end