html-format
Format HTML strings.
Last updated 4 years ago by mohd-akram .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install html-format 
SYNC missed versions from official npm registry.

html-format

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

Install

npm install html-format

Usage

import format from "html-format";

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

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

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

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

Current Tags

  • 1.1.7                                ...           latest (3 years ago)

12 Versions

  • 1.1.7                                ...           3 years ago
  • 1.1.6                                ...           3 years ago
  • 1.1.5                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.0.1-security                                ...           8 years ago
Maintainers (1)
Downloads
Total 11
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 2
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE