Skip to content

Commit 1cfaa9a

Browse files
committed
Initial commit
0 parents  commit 1cfaa9a

14 files changed

+459
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,remarkrc,eslintrc,sh}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage/
2+
example.js
3+
hast-util-embedded.js
4+
hast-util-embedded.min.js

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "eslint:recommended",
3+
"rules": {
4+
"quotes": [2, "single"]
5+
}
6+
}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
*.log
3+
coverage/
4+
node_modules/
5+
hast-util-embedded.js
6+
hast-util-embedded.min.js

.jscs.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"excludeFiles": [
3+
"coverage/",
4+
"node_modules/",
5+
"hast-util-embedded.js",
6+
"hast-util-embedded.min.js"
7+
],
8+
"preset": "crockford",
9+
"requireMultipleVarDecl": false,
10+
"disallowDanglingUnderscores": false,
11+
"requireQuotedKeysInObjects": true,
12+
"disallowKeywords": [
13+
"with"
14+
],
15+
"maximumLineLength": {
16+
"value": 79,
17+
"allExcept": [
18+
"regex",
19+
"urlComments"
20+
]
21+
},
22+
"jsDoc": {
23+
"checkAnnotations": "jsdoc3",
24+
"checkParamExistence": true,
25+
"checkParamNames": true,
26+
"checkRedundantAccess": true,
27+
"checkRedundantParams": true,
28+
"checkRedundantReturns": true,
29+
"checkReturnTypes": true,
30+
"checkTypes": "strictNativeCase",
31+
"enforceExistence": true,
32+
"requireHyphenBeforeDescription": true,
33+
"requireNewlineAfterDescription": true,
34+
"requireParamDescription": true,
35+
"requireParamTypes": true,
36+
"requireReturnDescription": true,
37+
"requireReturnTypes": true
38+
}
39+
}

.remarkrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"output": true,
3+
"plugins": [
4+
"lint",
5+
"github",
6+
"comment-config",
7+
"usage",
8+
"validate-links"
9+
],
10+
"settings": {
11+
"bullet": "*"
12+
}
13+
}

.travis.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'
4+
- '0.11'
5+
- '0.12'
6+
- '4.0'
7+
- '5.0'
8+
sudo: false
9+
after_script: npm install codecov.io && cat ./coverage/lcov.info | codecov
10+
deploy:
11+
- provider: npm
12+
13+
api_key:
14+
secure: AoLYsh2p2yxV0RKOPyqO7j/Zan53n5msO6rQWG+awi8ZEjW0PsHySTF69KkwnNEXWsFpyUY4C++FgyXNfqGLLHV7ut9TK8SqMhs9Az3JdTO9KYU3T9CG/XbuF6GTdv8Nqja1dWfhG5nDNpjK7pcuZKF+q8LddVnfkGX/BmiSJaElyQNXG+WQCjTPoUMzHwNju0Pk8RUcdJNvvVfj+F27OGhCNhfZohgqAbq7dDyst9yI24+y1W3mnnhPOujSx6NlC8mfrteiK1zMnod93i+t2U1xpT3BPglRvXKG2FoLLI35d3VByBk8esUodFYR/BPtS64k/nnL7UtQJDtPKPl+ErdzLh1v1/KkBkGKSNbRziwbc2hUmwihh3cySISL/DMcSm1ehPlezc0N8le9SzCMaJNjeVhKuxU+HdHo05pSseEvYB0JTbxCnYi/xqODwvEqbRyIozhQijXgeoKxpRGdX27t4MU4qg6Z3Qi56ldwLFH3fmTtZkeljP7KEcu9QoSMzzPOXNYb142Zx4whM8vH7uDXvfQZ1drMFlShWA85X+bZqCLDV6pozGssmrgrsXYQQDS5kFLT1FFAeAetY/RVAdVnqytRhd7MzFV9/tEHgN/3lya/7UMsNUASXhs4Zjj5a1In0Rl+hSNuFmkjIMNJDDya+6ilVNEdBpLtFbXVJQU=
15+
on:
16+
tags: true
17+
node: '5.0'
18+
- provider: releases
19+
api_key:
20+
secure: oMHI2yYeVS1263URexHk2jhwY7oPaYt7IBDc7hhgb/83TBgDWasUV4MUNsMQxriCkk3dawx0We91Rksq7QkC2V5VLC2Ki17h+WoC6HkmTVPQ5dYaAM7BG3Lc0UYDKCP+ZahGOKJIf1gxYczigeD/dX0ZeJXGdODb3JOS31BZ+pxEC0SbTxEgpL7OPOIdWfou3jnrFRWTt4N5FOfSiJAuO2oZ3ZkkjfWF3+bijiL8V6xDAoP14QFtsG7tLmMY/1TasZ2bcMb8AgSWOY4pEWThNurndn+c33VzyinvvSsRFMYLpT3vpFKCxTSudsxBg5Gyl0iNWBodBvqFhiiN1SdGv7SZ3TQgly7DJDL5QMNmIcna7ItUkrNXilHhfsKyoYNEXEz9ir0H7dZPIDCF7ULQZE58r8bSdi9PP3P5aKjyKO5Mx9Ap4jNupyCVCt6p4PTua9pLo/slV86TsLZIYIHUrkFclK2krHJG2nwsdvgLS8h0+dfdp5lP1gXIvm9l5GYVPkbMHcKuPhmkpr8D5csYnIJrLhm8XUaRakacE/4gY4ovDf0r3K486+sPK5+1uE5Gvlgnu4O4OAEjeIG52XvccKd2MmnKNef5k3WX3d4KnpxyRQ3mJ5FnnJ7VpqnxR9matrvf9BFQ3p1o5rfwrSKSvUB4kopSSeSkZ1+WAcwkQcU=
21+
file:
22+
- "hast-util-embedded.js"
23+
- "hast-util-embedded.min.js"
24+
on:
25+
tags: true

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2016 Titus Wormer <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

example.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Dependencies:
2+
var embedded = require('./index.js');
3+
4+
// Given a non-embedded value:
5+
var result = embedded({
6+
'type': 'element',
7+
'tagName': 'a',
8+
'properties': {
9+
'href': '#alpha',
10+
'title': 'Bravo'
11+
},
12+
'children': [{
13+
'type': 'text',
14+
'value': 'Charlie'
15+
}]
16+
});
17+
18+
// Yields:
19+
console.log('js', String(result));
20+
21+
// Given a embedded element:
22+
result = embedded({
23+
'type': 'element',
24+
'tagName': 'audio',
25+
'properties': {
26+
'src': 'delta.ogg'
27+
},
28+
'children': []
29+
});
30+
31+
// Yields:
32+
console.log('js', String(result));

history.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--remark setext-->
2+
3+
<!--lint disable no-multiple-toplevel-headings-->
4+
5+
0.0.0 / 2016-04-17
6+
==================

index.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2016 Titus Wormer
4+
* @license MIT
5+
* @module rehype:lint:util:embedded
6+
*/
7+
8+
'use strict';
9+
10+
/* eslint-env commonjs */
11+
12+
/*
13+
* Dependencies.
14+
*/
15+
16+
var is = require('hast-util-is-element');
17+
18+
/*
19+
* Tag-names.
20+
*/
21+
22+
var names = [
23+
'audio',
24+
'canvas',
25+
'embed',
26+
'iframe',
27+
'img',
28+
'math',
29+
'object',
30+
'picture',
31+
'svg',
32+
'video'
33+
];
34+
35+
/**
36+
* Check if a node is a embedded element
37+
*
38+
* @param {*} node - Thing to check.
39+
* @return {boolean} - Whether a node is embedded.
40+
*/
41+
function embedded(node) {
42+
return is(node, names);
43+
}
44+
45+
/*
46+
* Expose.
47+
*/
48+
49+
module.exports = embedded;

package.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "hast-util-embedded",
3+
"version": "0.0.0",
4+
"description": "Check if a node is a embedded element",
5+
"license": "MIT",
6+
"keywords": [
7+
"hast",
8+
"html",
9+
"category",
10+
"embedded",
11+
"util",
12+
"utility"
13+
],
14+
"dependencies": {
15+
"hast-util-is-element": "^1.0.0"
16+
},
17+
"files": [
18+
"index.js"
19+
],
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/wooorm/hast-util-embedded.git"
23+
},
24+
"bugs": "https://github.com/wooorm/hast-util-embedded/issues",
25+
"author": "Titus Wormer <[email protected]> (http://wooorm.com)",
26+
"contributors": [
27+
"Titus Wormer <[email protected]> (http://wooorm.com)"
28+
],
29+
"devDependencies": {
30+
"browserify": "^13.0.0",
31+
"eslint": "^2.0.0",
32+
"esmangle": "^1.0.1",
33+
"istanbul": "^0.4.0",
34+
"jscs": "^3.0.0",
35+
"jscs-jsdoc": "^2.0.0",
36+
"remark": "^4.0.0",
37+
"remark-comment-config": "^3.0.0",
38+
"remark-github": "^4.0.1",
39+
"remark-lint": "^3.0.0",
40+
"remark-usage": "^3.0.0",
41+
"remark-validate-links": "^3.0.0",
42+
"tape": "^4.4.0"
43+
},
44+
"scripts": {
45+
"build-md": "remark . --quiet --frail",
46+
"build-bundle": "browserify index.js --bare -s hastUtilEmbedded > hast-util-embedded.js",
47+
"build-mangle": "esmangle hast-util-embedded.js > hast-util-embedded.min.js",
48+
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
49+
"lint-api": "eslint .",
50+
"lint-style": "jscs --reporter inline .",
51+
"lint": "npm run lint-api && npm run lint-style",
52+
"test-api": "node test.js",
53+
"test-coverage": "istanbul cover test.js",
54+
"test": "npm run build && npm run lint && npm run test-coverage"
55+
}
56+
}

readme.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# hast-util-embedded [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page]
2+
3+
Check if a [node][] is a [**embedded**][spec] [element][].
4+
5+
## Installation
6+
7+
[npm][]:
8+
9+
```bash
10+
npm install hast-util-embedded
11+
```
12+
13+
**hast-util-embedded** is also available as an AMD, CommonJS, and
14+
globals module, [uncompressed and compressed][releases].
15+
16+
## Usage
17+
18+
Dependencies:
19+
20+
```javascript
21+
var embedded = require('hast-util-embedded');
22+
```
23+
24+
Given a non-embedded value:
25+
26+
```javascript
27+
var result = embedded({
28+
'type': 'element',
29+
'tagName': 'a',
30+
'properties': {
31+
'href': '#alpha',
32+
'title': 'Bravo'
33+
},
34+
'children': [{
35+
'type': 'text',
36+
'value': 'Charlie'
37+
}]
38+
});
39+
```
40+
41+
Yields:
42+
43+
```js
44+
false
45+
```
46+
47+
Given a embedded element:
48+
49+
```javascript
50+
result = embedded({
51+
'type': 'element',
52+
'tagName': 'audio',
53+
'properties': {
54+
'src': 'delta.ogg'
55+
},
56+
'children': []
57+
});
58+
```
59+
60+
Yields:
61+
62+
```js
63+
true
64+
```
65+
66+
## API
67+
68+
### `embedded(node)`
69+
70+
Check if the given value is an [**embedded**][spec] [element][].
71+
72+
**Parameters**: `node` (`*`) — Value to check.
73+
74+
**Returns**: `boolean`, whether `node` passes the test.
75+
76+
## License
77+
78+
[MIT][license] © [Titus Wormer][author]
79+
80+
<!-- Definition -->
81+
82+
[build-badge]: https://img.shields.io/travis/wooorm/hast-util-embedded.svg
83+
84+
[build-page]: https://travis-ci.org/wooorm/hast-util-embedded
85+
86+
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/hast-util-embedded.svg
87+
88+
[coverage-page]: https://codecov.io/github/wooorm/hast-util-embedded?branch=master
89+
90+
[npm]: https://docs.npmjs.com/cli/install
91+
92+
[releases]: https://github.com/wooorm/hast-util-embedded/releases
93+
94+
[license]: LICENSE
95+
96+
[author]: http://wooorm.com
97+
98+
[node]: https://github.com/wooorm/hast#node
99+
100+
[element]: https://github.com/wooorm/hast#element
101+
102+
[spec]: https://html.spec.whatwg.org/#embedded-content-2

0 commit comments

Comments
 (0)