https://github.com/specious/htmlflow
Lightweight HTML formatter that uses htmlparser2
https://github.com/specious/htmlflow
Last synced: 2 months ago
JSON representation
Lightweight HTML formatter that uses htmlparser2
- Host: GitHub
- URL: https://github.com/specious/htmlflow
- Owner: specious
- Created: 2021-08-10T21:38:55.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-25T17:41:38.000Z (almost 3 years ago)
- Last Synced: 2025-03-05T08:16:51.252Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Lightweight and fast single-pass HTML formatter that uses [htmlparser2](https://github.com/fb55/htmlparser2)
## Description
This HTML formatter is optimized for speed and configurability. Although it may incidentally fix certain issues with malformed HTML, it is designed to work properly only with already valid markup.
## Install
```
npm i @specious/htmlflow
```## Usage
```js
const htmlflow = require('@specious/htmlflow')
const fs = require('fs');(async () => {
let content = fs.readFileSync('./index.html')
let formatted = await htmlflow(content, {
indent: 2,
tabs: false,
spacesPerTab: 4,
formatting: true,
comments: true
})console.log(formatted)
})()
```