1.1.3 • Published 10 years ago

strip-comment v1.1.3

Weekly downloads
65
License
ISC
Repository
github
Last release
10 years ago

strip-comment

Strip js, css, and html comments.

Install

npm install strip-comment --save

test

mocha

demo

<style>
p {
    color: red;
    /* Css line comment */
    text-align: center;
}
/*
 * Css block comment 
 */
</style>
<!-- html comment -->
<p>This is a paragraph.</p>
// html content

<script>
/*
 * Js block comemnt
 */
function displayMsg() {
  // Js line comment
  alert("Hello World!")
}
</script>
var fs = require('fs');
var html = fs.readFileSync('./index.html', { encoding: 'utf8' });
var strip = require('strip-comment');

strip(html);  // Strip js css and html comments.

API

strip(code, keep)

Strip html css and js comments

  • {string} code required
  • {boolean} keep keep = false
    Keep the source code lines and columns

.js(code, keep)

Strip js comments

var js = 'var a = 3; // comment'
strip.js(js);
strip.js(js, true);     // keep code lines

.css(code, keep)

Strip css comments

var css = 'h2 { /* comment */ font-size : 18px; }'
strip.css(css);

.html(code, keep)

Strip html comments

var html = '<!-- html comment --><div></div>'
strip.html(html);
1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago