linegauge/strip
Every export of linegauge/strip, with its signature and doc comment: strip, strip.
import strip from 'linegauge/strip';
import { strip } from 'linegauge/strip';Functions
default
The default export, declared as strip.
Everything a terminal would print, with the escape sequences removed: CSI (SGR and the
cursor and erase forms), OSC including OSC 8 hyperlinks under both terminators, DCS, the
charset selections, and the single-character escapes. A lone ESC with nothing that parses
after it is text and is kept — the same answer strip-ansi gives.
Two passes, which is the design's prescription taken literally: "using
util.stripVTControlCharacters where it is exact and a local scan where it is not."
- The local scan, over
style.ts'sANSI_ESCAPE. It removes CSI and OSC including the colon form of an extended colour, which is the one shape Node gets wrong. - Node's stripper on what is left — the single-character escapes (
ESC c), the charset selections (ESC ( B) and a truncated sequence at the end of a string.ANSI_ESCAPEmatches none of those, becausewrapnever needed them: it was built to find the sequences it has to reopen, and a charset selection is not one.
Order is load-bearing. Ours runs first so the colon form is already gone by the time Node
sees the string; reversed, pass 2 would leave :2::255:0:0m behind as text and pass 1
would have nothing left to match.
function strip(string: string): string;| Parameter | Type |
|---|---|
string | string |
Returns string
strip
Everything a terminal would print, with the escape sequences removed: CSI (SGR and the
cursor and erase forms), OSC including OSC 8 hyperlinks under both terminators, DCS, the
charset selections, and the single-character escapes. A lone ESC with nothing that parses
after it is text and is kept — the same answer strip-ansi gives.
Two passes, which is the design's prescription taken literally: "using
util.stripVTControlCharacters where it is exact and a local scan where it is not."
- The local scan, over
style.ts'sANSI_ESCAPE. It removes CSI and OSC including the colon form of an extended colour, which is the one shape Node gets wrong. - Node's stripper on what is left — the single-character escapes (
ESC c), the charset selections (ESC ( B) and a truncated sequence at the end of a string.ANSI_ESCAPEmatches none of those, becausewrapnever needed them: it was built to find the sequences it has to reopen, and a charset selection is not one.
Order is load-bearing. Ours runs first so the colon form is already gone by the time Node
sees the string; reversed, pass 2 would leave :2::255:0:0m behind as text and pass 1
would have nothing left to match.
function strip(string: string): string;| Parameter | Type |
|---|---|
string | string |
Returns string