Skip to content

Commit b3b4f75

Browse files
committed
chore: update README
1 parent a3d8afb commit b3b4f75

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,27 @@ const output = await render(ast);
5959

6060
#### `transform`
6161

62-
The `transform` function provides a straight-forward way to swap in-place elements (or Components) and update them with a new value. It is a shortcut that combines `parse` and `render`.
63-
64-
> **Note**
65-
> By default, `transform` will sanitize your markup, removing any `script` tags. Pass `{ sanitize: false }` to disable this behavior.
62+
The `transform` function provides a straight-forward way to modify any markup. Sanitize content, swap in-place elements/Components, and more using a set of built-in transformers, or write your own custom transformer.
6663

6764
```js
6865
import { transform, html } from "ultrahtml";
69-
70-
const output = await transform(`<h1>Hello world!</h1>`, {
71-
components: {
72-
h1: (props, children) => html`<h1 class="ultra">${children}</h1>`,
73-
},
74-
});
75-
76-
console.log(output); // <h1 class="ultra">Hello world!</h1>
66+
import swap from "ultrahtml/transformers/swap";
67+
import sanitize from "ultrahtml/transformers/sanitize";
68+
69+
const output = await transform(`<h1>Hello world!</h1>`, [
70+
swap({
71+
h1: "h2",
72+
h3: (props, children) => html`<h2 class="ultra">${children}</h2>`,
73+
}),
74+
sanitize({ allowElements: ["h1", "h2", "h3"] }),
75+
]);
76+
77+
console.log(output); // <h2>Hello world!</h2>
7778
```
7879

7980
#### Sanitization
8081

81-
`ultrahtml` implements an extension of the [HTML Sanitizer API](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/Sanitizer). This is enabled by default, but can be turned off by passing `{ sanitize: false }` to `render` and `transform`.
82+
`ultrahtml/transformers/sanitize` implements an extension of the [HTML Sanitizer API](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/Sanitizer).
8283

8384
| Option | Type | Default | Description |
8485
| ------------------- | -------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

0 commit comments

Comments
 (0)