The Wayback Machine - https://web.archive.org/web/20201208125248/https://github.com/mohd-akram/html-format
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

html-format

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

Install

npm install html-format

Usage

const format = require('html-format');

const html = `\
<body>
<main class="bg">   </main>
</body>
`;

// indent = 2 spaces (default), width = 80 characters (default)
format(html) == `\
<body>
  <main class="bg"> </main>
</body>
`;

// indent = 4 spaces, width = 80 characters (default)
format(html, ' '.repeat(4)) == `\
<body>
    <main class="bg"> </main>
</body>
`;

// indent = 4 spaces, width = 20 characters
format(html, ' '.repeat(4), 20) == `\
<body>
    <main
        class="bg">
    </main>
</body>
`;

About

A Node.js library for formatting HTML strings

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.