# Module /repr/html

SHTML (#shtml / #html) node renderer, attribute/class utilities, and template formatter (format-html).

```tangu
(use /repr/html)
```

## Functions & symbols

### add-classes

`(add-classes attrs ...classes) -> None`

Mutates `attrs:class` in place by appending `classes` without overwriting existing classes.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `attrs` | `Map` | no | Mutable attributes Map |
| `classes` | `Any` | no | One or more class names/arrays/maps |

```tangu
(repr-html/add-classes attrs "card" "elevated")
```

### escape-html

`(escape-html text) -> String`

Escapes HTML special characters (`&`, `<`, `>`, `"`, `'`) for safe text/attribute interpolation.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `text` | `Any` | no | Raw text or value to escape |

```tangu
(repr-html/escape-html "<script>") ; -> "&lt;script&gt;"
```

### format-class

`(format-class value) -> Array`

Normalizes class strings, nested arrays, or conditional maps into a flat deduplicated Array of class tokens.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `value` | `Any` | no | Class name String, Array, or Map of {:cls bool} |

```tangu
(repr-html/format-class ["btn" {"is-active" true}])
```

### format-html

`(format-html html-expr) -> String`

Renders an `#shtml` / `#html` expression tree into valid HTML5 (normalizing boolean attributes per §2.4.2).

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `html_expr` | `Any` | no | Evaluated SHTML node or list of nodes |

```tangu
(repr-html/format-html #shtml [:p {:class "lead"} "Hello"])
```

### format-html-template

`(format-html-template chunks slots [flags]) -> String`

Runtime helper compiling interpolated HTML template literals safely.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `chunks` | `Array` | no | Static HTML template chunks |
| `slots` | `Array` | no | Interpolated slot values |
| `flags` | `String` | yes | Optional compiler escape mode flags |

```tangu
(repr-html/format-html-template ["<p>" "</p>"] ["Hi"])
```

### merge-attrs

`(merge-attrs ...maps) -> Map`

Merges attribute Maps left-to-right while cleanly concatenating `:class` lists instead of replacing them.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `maps` | `Map` | no | Attribute maps to merge left-to-right |

```tangu
(repr-html/merge-attrs {:class "btn"} extra-attrs)
```

### parse-component-params

`(parse-component-params params-arr) -> Map`

Normalizes `#shtml` custom component parameters into `{:attrs Map :children Array}`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `params` | `Array` | no | Variadic SHTML component body `[attrs? ...children]` |

```tangu
(let {:attrs attrs :children children} (repr-html/parse-component-params params))
```

### shtml->html

`(shtml->html html-expr) -> String`

Canonical alias of `format-html`: serializes `#shtml` nodes to an HTML string.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `html_expr` | `Any` | no | Evaluated SHTML node tree |

```tangu
(repr-html/shtml->html [:div "Hello"])
```
