Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/indent_and_wrap/private/indent.ts>findCommonIndent

Finds and replaces common indent, hard-wraps text, generates text tables and table-based complex text layouts. Can work on text that contains terminal escape sequences.
Go to Latest
function findCommonIndent
import { findCommonIndent } from "https://deno.land/x/indent_and_wrap@v0.0.15/private/indent.ts";

Scan text string, and find leading space characters, that are common across all lines. If ignoreFirstIndent is set, then the leading space on the first line is not counted, so the provided text string can be trimmed. If options.mode is term, then terminal escape sequences (like VT100 color codes) can be part of indent. This function uses fast algorithm that avoids splitting text to lines array.

Parameters

text: string
optional
options: FindCommonIndentOptions