You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ xx.xx.xxxx
21
21
***Feature** - Added [`addAttr()`](https://next.semantic-ui.com/api/query/attributes#addattr) method for adding one or more attributes with empty string values. Useful shorthand for boolean attributes common in web components.
22
22
23
23
### Utils
24
+
***Feature** - Added [`indentHTML()`](https://next.semantic-ui.com/docs/api/utils/html#indenthtml) for intelligently indenting HTML markup with proper nesting awareness. Handles void elements, self-closing tags, and comments correctly. Perfect for cleaning up HTML extracted from template literals.
25
+
***Feature** - Added [`indentLines()`](https://next.semantic-ui.com/docs/api/utils/html#indentlines) for adding consistent indentation to every line of text. Useful for formatting code snippets and template processing.
24
26
***Feature** - Added `reverseString()` for reversing strings with Unicode grapheme cluster handling using Intl.Segmenter. Preserves emojis, flag sequences, skin tone modifiers, and combined diacritics.
25
27
***Bug** - Fixed `weightedObjectSearch()` regex pattern escaping where multi-word queries with `matchAllWords: false` returned no results. Template string was using `\W` (literal 'W') instead of `\\W` (non-word character class), breaking word boundary matching.
26
28
***Enhancement** - `remove()` now removes all matching instances from an array instead of just the first. Uses an optimized two-pointer approach for O(n) performance. Returns the count of removed elements for backward compatibility.
description: API reference for HTML and text formatting utility functions
7
+
---
8
+
9
+
The HTML utilities provide functions for indenting text and HTML markup. These functions are useful for formatting code snippets, cleaning up HTML extracted from template literals, and preparing markup for documentation.
10
+
11
+
## Functions
12
+
13
+
### indentLines
14
+
15
+
```javascript
16
+
functionindentLines(text, spaces=2)
17
+
```
18
+
19
+
Adds consistent indentation to every line of text.
20
+
21
+
#### Parameters
22
+
23
+
| Name | Type | Description |
24
+
|--------|--------|-------------|
25
+
| text | string | The text to indent |
26
+
| spaces | number | Number of spaces to indent each line (default: 2) |
27
+
28
+
#### Returns
29
+
30
+
The indented text. Returns empty string for non-string input.
31
+
32
+
#### Example
33
+
34
+
```javascript
35
+
import { indentLines } from '@semantic-ui/utils';
36
+
37
+
constcode='line 1\nline 2\nline 3';
38
+
console.log(indentLines(code)); // ' line 1\n line 2\n line 3'
39
+
console.log(indentLines(code, 4)); // ' line 1\n line 2\n line 3'
Intelligently indents HTML markup with proper nesting awareness. Handles void elements, self-closing tags, and comments correctly.
55
+
56
+
> **Use Case** Perfect for cleaning up HTML extracted from JavaScript template literals where indentation gets messy, or for formatting documentation examples.
0 commit comments