Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
clean-html
Advanced tools
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>
<blockquote>
<!-- List articles -->
<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>
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];
fs.readFile(file, 'utf-8', function (err, data) {
process.stdout.write(cleaner.clean(data) + '\n');
});
Sanity restored!
<table>
<tr>
<td>
<b>Currently we have these articles available:</b>
<blockquote>
<!-- List articles -->
<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>
If you like, you can even close the empty tags, lose the comments and get rid of that nasty presentational markup:
var options = {
'close-empty-tags': true,
'remove-comments': true,
'add-tags-to-remove': ['table', 'tr', 'td', 'blockquote']
};
process.stdout.write(cleaner.clean(data, options) + '\n');
Voila!
<b>Currently we have these articles available:</b>
<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>
Attributes to remove from markup.
Type: Array
Default: ['align', 'valign', 'bgcolor', 'color', 'width', 'height', 'border', 'cellpadding', 'cellspacing']
Block level element tags. Line breaks are added before and after, and nested content is indented. Note: this option has no effect unless pretty is set to true.
Type: Array
Default: ['div', 'p', 'table', 'tr', 'td', 'blockquote', 'hr']
Adds line breaks after br tags. Note: this option has no effect unless pretty is set to true.
Type: Boolean
Default: true
If set to true, adds trailing slashes to empty tags. Otherwise removes trailing slashes.
Type: Boolean
Default: false
Empty element tags.
Type: Array
Default: ['br', 'hr', 'img']
The string to use for indentation. e.g., a tab character or one or more spaces. Note: this option has no effect unless pretty is set to true.
Type: String
Default: ' '
(two spaces)
Pretty prints the output by adding line breaks and indentation.
Type: Boolean
Default: true
Removes comments.
Type: Boolean
Default: false
Tags to remove from markup.
Type: Array
Default: ['font']
These options are added for your convenience.
Additional attributes to remove from markup.
Type: Array
Default: null
Additional block level element tags.
Type: Array
Default: null
Additional empty element tags.
Type: Array
Default: null
Additional tags to remove from markup.
Type: Array
Default: null
FAQs
HTML cleaner and beautifier
We found that clean-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.