Skip to content
Snippets Groups Projects
Commit ebafd86d authored by Praveen Arimbrathodiyil's avatar Praveen Arimbrathodiyil
Browse files

Import Upstream version 1.1.1

parents
No related branches found
No related tags found
No related merge requests found
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
* text=auto
/node_modules/
npm-debug.log
{
"preset": "google",
"maximumLineLength": null,
"excludeFiles": ["node_modules/**"]
}
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"latedef": true,
"mocha" : true,
"newcap": true,
"noarg": true,
"node": true,
"sub": true,
"undef": true,
"unused": true
}
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
> Regular expression for matching HTML comments
## Install
```sh
$ npm install --save html-comment-regex
```
## Usage
```js
var htmlCommentRegex = require('html-comment-regex');
htmlCommentRegex.test('<!DOCTYPE html><!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body></body></html>');
//=> true
htmlCommentRegex.test('<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body></body></html>');
//=> false
```
## License
MIT © [Steve Mao](https://github.com/stevemao)
[npm-image]: https://badge.fury.io/js/html-comment-regex.svg
[npm-url]: https://npmjs.org/package/html-comment-regex
[travis-image]: https://travis-ci.org/stevemao/html-comment-regex.svg?branch=master
[travis-url]: https://travis-ci.org/stevemao/html-comment-regex
'use strict';
module.exports = /<!--([\s\S]*?)-->/g;
{
"name": "html-comment-regex",
"version": "1.1.1",
"description": "Regular expression for matching HTML comments",
"homepage": "https://github.com/stevemao/html-comment-regex",
"author": {
"name": "Steve Mao",
"email": "maochenyan@gmail.com",
"url": "https://github.com/stevemao"
},
"repository": "stevemao/html-comment-regex",
"license": "MIT",
"files": [
"index.js"
],
"keywords": [
"html-comment-regex",
"text",
"string",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern",
"comment",
"comments",
"html",
"HTML",
"HyperText Markup Language"
],
"dependencies": {},
"devDependencies": {
"jscs": "^1.11.3",
"jshint": "^2.6.3",
"mocha": "*"
},
"scripts": {
"lint": "jshint *.js --exclude node_modules && jscs *.js",
"test": "npm run-script lint && mocha"
}
}
test.js 0 → 100644
'use strict';
var assert = require('assert');
var htmlCommentRegex = require('./');
var html = '<!DOCTYPE html><!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!-- normal comment 1 --><!--normal comment 2--> <html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body></body></html>';
it('html should match the regex', function() {
var result = htmlCommentRegex.exec(html);
assert.deepEqual(result[0], '<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->');
assert.deepEqual(result[1], '[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]');
result = htmlCommentRegex.exec(html);
assert.deepEqual(result[0], '<!-- normal comment 1 -->');
assert.deepEqual(result[1], ' normal comment 1 ');
result = htmlCommentRegex.exec(html);
assert.deepEqual(result[0], '<!--normal comment 2-->');
assert.deepEqual(result[1], 'normal comment 2');
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment