Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-format

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-format

Format HTML strings.

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3K
decreased by-48.85%
Maintainers
1
Weekly downloads
 
Created
Source

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>
`;

Keywords

FAQs

Package last updated on 20 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc