Socket
Socket
Sign inDemoInstall

clean-html

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-html

Do you have crappy HTML? I do!


Version published
Weekly downloads
3.1K
decreased by-2.15%
Maintainers
1
Weekly downloads
 
Created
Source

HTML cleaner and beautifier

Do you have crappy HTML? I do!

<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="31"><b>Currently we have these articles available:</b>

        <!-- This is so ugly! -->
        <blockquote>
              <p><a href="foo.html">The History of Foo</a><br />    
                An <span color="red">informative</span> piece  of <FONT FACE="ARIAL">information</FONT>.</p>
              <p><a href="bar.html">A Horse Walked Into a Bar</a><br/> The bartender said
                "Why the long face?"</p>
	</blockquote>
          </td>
        </tr>
      </table>

Can you stand to look at it? Just look at those blank lines and random line breaks, trailing spaces, mixed tabs, deprecated tags... it's outrageous!

Let's clean it up...

$ npm install clean-html
var cleaner = require('clean-html'),
    fs = require('fs'),
    file = process.argv[2],
    options = {'pretty': true};

fs.readFile(file, function (err, data) {
    process.stdout.write(cleaner.clean(data, options) + '\n');
});

Sanity restored!

<table>
  <tr>
    <td>
      <b>Currently we have these articles available:</b>
      <blockquote>
        <p>
          <a href="foo.html">The History of Foo</a><br>
          An <span>informative</span> piece of information.
        </p>
        <p>
          <a href="bar.html">A Horse Walked Into a Bar</a><br>
          The bartender said "Why the long face?"
        </p>
      </blockquote>
    </td>
  </tr>
</table>

Keywords

FAQs

Package last updated on 13 Apr 2015

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