Skip to content

Commit e2c9410

Browse files
authored
docs: polish the README header, features and table of contents (#3)
1 parent 4729976 commit e2c9410

1 file changed

Lines changed: 37 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1+
<div align="center">
2+
13
# react-html5-parser
24

3-
Fast, simple and small HTML to React parser for the browser and React Native, sanitized by default
5+
**Turn HTML strings into React and React Native elements, sanitized by default.**
46

57
[![npm version](https://img.shields.io/npm/v/react-html5-parser)](https://www.npmjs.com/package/react-html5-parser)
8+
[![npm downloads](https://img.shields.io/npm/dm/react-html5-parser)](https://www.npmjs.com/package/react-html5-parser)
9+
[![types](https://img.shields.io/npm/types/react-html5-parser)](#other-exports)
610
[![CI](https://img.shields.io/github/actions/workflow/status/devmaxxx/react-html5-parser/ci.yml?branch=main&label=CI)](https://github.com/devmaxxx/react-html5-parser/actions/workflows/ci.yml)
711
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
812

9-
- Turns an HTML string into React elements, with no `dangerouslySetInnerHTML`.
10-
- Sanitized by default with DOMPurify, run on the parsed tree so nothing is parsed twice.
11-
- Swap any tag for your own component, or rewrite nodes and elements as they render.
12-
- A 3 kB core entry for when you bring your own sanitizer.
13-
- A React Native entry that renders `View`, `Text` and `Image`.
14-
- Never throws on bad input: returns `null` and reports through `onError`.
15-
- ESM and CommonJS builds, with TypeScript types.
13+
[Install](#install) · [Use](#use) · [API](#api) · [React Native](#react-native) · [Examples](EXAMPLES.md) · [Changelog](CHANGELOG.md)
14+
15+
</div>
16+
17+
## Features
18+
19+
- **No `dangerouslySetInnerHTML`.** HTML becomes real React elements you can map, wrap and replace.
20+
- **Safe by default.** DOMPurify runs on the parsed tree, so nothing is parsed twice and the checked tree is the rendered tree.
21+
- **The browser's own HTML5 parser.** Markup is read exactly as the page would read it, inside an inert `<template>`.
22+
- **Your components.** Swap any tag for a component, or rewrite nodes and elements as they render.
23+
- **3 kB core** for HTML you trust or sanitize yourself.
24+
- **React Native** entry that renders `View`, `Text` and `Image`.
25+
- **Never throws** on bad input: returns `null` and reports through `onError`.
26+
- **ESM and CommonJS**, with TypeScript types for every entry.
27+
28+
## Contents
29+
30+
- [Install](#install)
31+
- [Use](#use)
32+
- [API](#api): [`parse`](#parse), [options](#options), [built-in sanitizer](#built-in-sanitizer), [`purify`](#purify), [`sanitize`](#sanitize), [`components`](#components), [`mapNode`](#mapnode), [`mapElement`](#mapelement), [`attrsMap`](#attrsmap), [`onError`](#onerror), [other exports](#other-exports)
33+
- [React Native](#react-native)
34+
- [Errors](#errors)
35+
- [Notes](#notes)
36+
- [Upgrading from 0.x](#upgrading-from-0x)
37+
- [Development](#development)
38+
- [Contributing](#contributing)
39+
- [License](#license)
1640

1741
## Install
1842

@@ -24,6 +48,8 @@ yarn add react-html5-parser
2448

2549
Requires React 18 or newer (`react >= 18`). The native entry also needs React Native 0.71 or newer.
2650

51+
The browser entries parse with the DOM, so on the server `parse` returns `null`. See [server rendering](EXAMPLES.md#server-rendering) for the client-side pattern.
52+
2753
## Use
2854

2955
Three entry points, one `parse` signature:
@@ -415,6 +441,8 @@ To release, bump `version` in `package.json`, add its section to `CHANGELOG.md`,
415441

416442
Issues and pull requests are welcome at [github.com/devmaxxx/react-html5-parser](https://github.com/devmaxxx/react-html5-parser). For a bug, include the HTML string and the options you passed to `parse`. A pull request should come with a test in `__tests__/` and keep `npm test` and `npm run build:size` green.
417443

444+
Release notes for every version are in [CHANGELOG.md](CHANGELOG.md) and on the [releases page](https://github.com/devmaxxx/react-html5-parser/releases).
445+
418446
## License
419447

420-
[MIT](LICENSE.md)
448+
[MIT](LICENSE.md) © Maksym Synenko

0 commit comments

Comments
 (0)