ctrl+k
Enter a search term above to see results...
Functions for indenting text and HTML markup.
Adds consistent indentation to every line of text.
indentLines(text, spaces = 2)| Name | Type | Description |
|---|---|---|
| text | string | The text to indent |
| spaces | number | Number of spaces to indent each line (default: 2) |
Indented text. Returns empty string for non-string input.
Indents HTML markup with nesting awareness.
indentHTML(html, { indent = ' ', startLevel = 0, trimEmptyLines = true } = {})| Name | Type | Description |
|---|---|---|
| html | string | The HTML string to indent |
| options | object | Optional configuration |
| Name | Type | Default | Description |
|---|---|---|---|
| indent | string | ’ ‘ | String to use for each level of indentation |
| startLevel | number | 0 | Initial nesting level to start indentation from |
| trimEmptyLines | boolean | true | Whether to remove empty lines from the output |
Indented HTML. Returns empty string for non-string input.
Handles void elements (img, br, hr, input), self-closing tags (<component />), comments, and same-line tags (<tag>content</tag>).