Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Mao committed May 21, 2015
0 parents commit 2dbb3be
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 1,12 @@
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 1,2 @@
/node_modules/
npm-debug.log
5 changes: 5 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
{
"preset": "google",
"maximumLineLength": null,
"excludeFiles": ["node_modules/**"]
}
15 changes: 15 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 1,15 @@
{
"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
}
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 1,6 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 1,34 @@
# [![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
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 1,2 @@
'use strict';
module.exports = /(<!--(?:.|\s)*?-->)/g;
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 1,43 @@
{
"name": "html-comment-regex",
"version": "0.0.0",
"description": "Regular expression for matching HTML comments",
"homepage": "https://github.com/stevemao/html-comment-regex",
"author": {
"name": "Steve Mao",
"email": "[email protected]",
"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"
}
}
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 1,14 @@
'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]--><!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--><!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--><!--[if gt IE 8]><!--><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body></body></html>';

it('html should match the regex', function() {
assert.deepEqual(html.match(htmlCommentRegex), [
'<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->',
'<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->',
'<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->',
'<!--[if gt IE 8]><!-->'
]);
});

0 comments on commit 2dbb3be

Please sign in to comment.