Skip to main content
Module

x/indent_and_wrap/mod.ts>findCommonIndent

Finds and replaces common indent, and hard-wraps text. 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.6/mod.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