Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mohd-akram/html-format

A Node.js library for formatting HTML strings
https://github.com/mohd-akram/html-format

html-format node nodejs npm

Last synced: 3 months ago
JSON representation

A Node.js library for formatting HTML strings

Awesome Lists containing this project

README

        

# html-format

Format HTML strings by indenting, wrapping, and removing unnecessary
whitespace while preserving newlines.

## Install

npm install html-format

## Usage

```javascript
import format from "html-format";

const html = `\

`;

// indent = 2 spaces (default), width = 80 characters (default)
format(html) ==
`\

`;

// indent = 4 spaces, width = 80 characters (default)
format(html, " ".repeat(4)) ==
`\

`;

// indent = 4 spaces, width = 20 characters
format(html, " ".repeat(4), 20) ==
`\


`;
```