# @prezly/docx-cleaner

> Normalize dirty HTML and DOCX/RTF documents into clean, understandable HTML

Latest version **0.5.2** (published 2023-04-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @prezly/docx-cleaner
pnpm add @prezly/docx-cleaner
yarn add @prezly/docx-cleaner
bun add @prezly/docx-cleaner
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.2 |
| Published | 2023-04-04 |
| First published | 2021-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 159.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Maintainers | mohammadxali, francis-prezly, zourdyzou, oskar-prezly, pestaa, aspirisen, kudlik, digitalbase, e1npm, satoav, makanda |

## Links

- npm: https://www.npmjs.com/package/@prezly/docx-cleaner
- Repository: https://github.com/prezly/docx-cleaner
- Homepage: https://github.com/prezly/docx-cleaner#readme
- Issues: https://github.com/prezly/docx-cleaner/issues
- npm.io page: https://npm.io/package/@prezly/docx-cleaner

## Dependencies (1)

- [validator](https://npm.io/package/validator.md) ^13.5.2

## Recent versions

- 0.5.2 (latest) — 2023-04-04
- 0.5.1 — 2021-12-30
- 0.5.0 — 2021-12-30
- 0.4.0 — 2021-11-09
- 0.3.0 — 2021-11-08
- 0.2.2 — 2021-10-28
- 0.2.1 — 2021-10-22
- 0.2.0 — 2021-10-21
- 0.2.0-alpha.3 — 2021-10-21
- 0.2.0-alpha.2 — 2021-10-21
- 0.2.0-alpha.1 — 2021-10-21
- 0.2.0-alpha.0 — 2021-10-20
- 0.1.8 — 2021-07-15
- 0.1.7 — 2021-07-14
- 0.1.6 — 2021-07-07
- … 26 more at https://npm.io/package/@prezly/docx-cleaner/versions

## README

# @prezly/docx-cleaner

Normalize dirty HTML and DOCX/RTF documents into clean, understandable HTML

![Version](https://img.shields.io/npm/v/@prezly/docx-cleaner)
![License](https://img.shields.io/npm/l/@prezly/docx-cleaner)

## Usage

```tsx
import React, { ClipboardEvent, useState } from 'react';
import { cleanDocx } from '@prezly/docx-cleaner';

const MyComponent = () => {
    const [value, setValue] = useState<string>('');

    function handlePaste(event: ClipboardEvent<HTMLTextAreaElement>) {
        const html = event.clipboardData.getData('text/html');
        const rtf = event.clipboardData.getData('text/rtf');

        try {
            const cleanHtml = cleanDocx(html, rtf);
            setValue(cleanHtml);
        } catch (error) {
            setValue(error.message);
            console.error(error);
        }
    };

    return <textarea value={value} onPaste={handlePaste} />;
};

export default MyComponent;
```

# Development

In order to start developing, run the build in watch mode.

## Setup

```Shell
npm install           # install dependencies
npm run build:watch   # start watcher
```

## Publishing

```Shell
npm run release     # reinstall & rebuild everything from scratch and...
                    # ...and run a wizard that'll guide you through publishing the npm package
```

----

Brought to you by [Prezly](https://www.prezly.com/?utm_source=github&utm_campaign=@prezly/docx-cleaner).

---
_Source: https://npm.io/package/@prezly/docx-cleaner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
