# normalize-html-whitespace

> Safely remove repeating whitespace from HTML text.

Latest version **1.0.0** (published 2019-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install normalize-html-whitespace
pnpm add normalize-html-whitespace
yarn add normalize-html-whitespace
bun add normalize-html-whitespace
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-02-25 |
| First published | 2015-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 8 |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Steven Vachon |
| Maintainers | stevenvachon |
| Keywords | collapse, compact, condense, html, minify, normalize, remove, space, str, string, strip, trim, whitespace |

## Links

- npm: https://www.npmjs.com/package/normalize-html-whitespace
- Repository: https://github.com/stevenvachon/normalize-html-whitespace
- Homepage: https://github.com/stevenvachon/normalize-html-whitespace#readme
- Issues: https://github.com/stevenvachon/normalize-html-whitespace/issues
- npm.io page: https://npm.io/package/normalize-html-whitespace

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-02-25
- 0.2.0 — 2015-12-15
- 0.1.0 — 2015-12-12

## README

# normalize-html-whitespace [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]

> Safely remove repeating whitespace from HTML text.


Using `\s` to normalize HTML whitespace will strip out characters that are actually rendered by a web browser. Such would be classified as a lossy change and would produce a different visual result. This package will collapse multiple whitespace characters down to a single space, while ignoring the following characters:

* `\u00a0` or `&nbsp;` (non-breaking space)
* `\ufeff` or `&#65279;` (zero-width non-breaking space)

…as well as these lesser-known ones:

* `\u1680`​ or `&#5760;` (Ogham space mark)
* `\u180e` or `&#6158;` (Mongolian vowel separator)
* `\u2000​` or `&#8192;` (en quad)
* `\u2001` or `&#8193;` (em quad)
* `\u2002` or `&#8194;` (en space)
* `\u2003` or `&#8195;` (em space)
* `\u2004` or `&#8196;` (three-per-em space)
* `\u2005` or `&#8197;` (four-per-em space)
* `\u2006` or `&#8198;` (six-per-em space)
* `\u2007` or `&#8199;` (figure space)
* `\u2008` or `&#8200;` (punctuation space)
* `\u2009` or `&#8201;` (thin space)
* `\u200a` or `&#8202;` (hair space)
* `\u2028` or `&#8232;` (line separator)
* `\u2029` or `&#8233;` (paragraph separator)
* `\u202f` or `&#8239;` (narrow non-breaking space)
* `\u205f` or `&#8287;` (medium mathematical space)
* `\u3000` or `&#12288;` (ideographic space)

For the sake of completeness, the following characters which are not part of `\s` will also not be affected:

* `\u200b` or `&#8203;` (zero-width breaking space)

Note: this package does not contain an HTML parser. It is meant to be used on text nodes only.


## Installation
[Node.js](http://nodejs.org/) `>= 8` is required. Type this at the command line:
```shell
npm install normalize-html-whitespace
```


## Usage
```js
const normalizeWhitespace = require('normalize-html-whitespace');

normalizeWhitespace('  foo bar     baz ');
//-> ' foo bar baz '
```


[npm-image]: https://img.shields.io/npm/v/normalize-html-whitespace.svg
[npm-url]: https://npmjs.com/package/normalize-html-whitespace
[travis-image]: https://img.shields.io/travis/stevenvachon/normalize-html-whitespace.svg
[travis-url]: https://travis-ci.org/stevenvachon/normalize-html-whitespace

---
_Source: https://npm.io/package/normalize-html-whitespace · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
