Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 8, 2016
0 parents commit 1c6eba7
Show file tree
Hide file tree
Showing 187 changed files with 7,169 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
*.log
coverage/
.nyc_output/
node_modules/
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- '0.11'
- '6.0'
after_success: bash <(curl -s https://codecov.io/bash)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(The MIT License)

Copyright (c) 2016 Titus Wormer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 4 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lerna": "2.0.0-beta.27",
"version": "independent"
}
5 changes: 5 additions & 0 deletions logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"private": true,
"name": "monorepo",
"license": "MIT",
"repository": "https://github.com/wooorm/rehype-minify",
"bugs": "https://github.com/wooorm/rehype-minify/issues",
"author": "Titus Wormer <[email protected]> (http://wooorm.com)",
"contributors": [
"Titus Wormer <[email protected]> (http://wooorm.com)"
],
"devDependencies": {
"bail": "^1.0.1",
"chalk": "^1.1.3",
"dox": "^0.9.0",
"execa": "^0.4.0",
"hastscript": "^3.0.0",
"is-hidden": "^1.0.1",
"lerna": "^2.0.0-beta.27",
"mdast-zone": "^3.0.0",
"negate": "^1.0.0",
"nyc": "^8.0.0",
"parse-author": "^1.0.0",
"rehype": "^3.0.0",
"rehype-cli": "^1.0.0",
"remark": "^6.0.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"strip-indent": "^2.0.0",
"tape": "^4.6.0",
"to-vfile": "^2.0.0",
"trim": "0.0.1",
"trim-trailing-lines": "^1.0.0",
"trough": "^1.0.0",
"uniq": "^1.0.1",
"unist-builder": "^1.0.2",
"vfile-find-down": "^2.0.1",
"xo": "^0.16.0",
"xtend": "^4.0.1"
},
"scripts": {
"prepublish": "lerna bootstrap",
"build-packages": "node script/build-packages",
"build-md": "remark . -qfo",
"build": "npm run build-packages && npm run build-md",
"lint": "xo",
"test-api": "tape test/index.js packages/*/test.js",
"test-coverage": "nyc --reporter lcov tape test/index.js packages/*/test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"xo": {
"space": true,
"rules": {
"guard-for-in": "off",
"no-eq-null": "off",
"eqeqeq": [
2,
"allow-null"
],
"camelcase": "off"
}
},
"remarkConfig": {
"presets": "wooorm"
}
}
27 changes: 27 additions & 0 deletions packages/hast-util-from-string/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @fileoverview
* Set the plain-text value of a HAST node.
* This is like the DOMs `Node#textContent` setter.
* The given node is returned.
*/

'use strict';

/* Expose. */
module.exports = fromString;

function fromString(node, value) {
var val = value == null ? '' : String(value);

if ('children' in node) {
node.children = [];

if (val) {
node.children.push({type: 'text', value: val});
}
} else {
node.value = val;
}

return node;
}
20 changes: 20 additions & 0 deletions packages/hast-util-from-string/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "hast-util-from-string",
"version": "0.0.0",
"description": "Set the plain-text value of a node",
"license": "MIT",
"keywords": [
"rehype",
"hast",
"string"
],
"repository": "https://github.com/wooorm/rehype-minify/tree/master/packages/hast-util-from-string",
"bugs": "https://github.com/wooorm/rehype-minify/issues",
"author": "Titus Wormer <[email protected]> (http://wooorm.com)",
"contributors": [
"Titus Wormer <[email protected]>"
],
"files": [
"index.js"
]
}
17 changes: 17 additions & 0 deletions packages/hast-util-from-string/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--This file is generated by `build-packages.js`-->

# hast-util-from-string

Set the plain-text value of a HAST node.
This is like the DOMs `Node#textContent` setter.
The given node is returned.

## Install

```sh
npm install hast-util-from-string
```

## License

[MIT](https://github.com/wooorm/rehype-minify/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
47 changes: 47 additions & 0 deletions packages/hast-util-from-string/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

/* eslint-disable import/no-extraneous-dependencies */

var test = require('tape');
var u = require('unist-builder');
var fromString = require('./');

test('hast-util-from-string', function (t) {
t.deepEqual(
fromString(u('text'), 'foo'),
u('text', 'foo'),
'should set text nodes'
);

t.deepEqual(
fromString(u('text')),
u('text', ''),
'should reset text nodes (1)'
);

t.deepEqual(
fromString(u('text', 'foo')),
u('text', ''),
'should reset text nodes (2)'
);

t.deepEqual(
fromString(u('element', {tagName: 'p'}, []), 'foo'),
u('element', {tagName: 'p'}, [u('text', 'foo')]),
'should set parent nodes'
);

t.deepEqual(
fromString(u('element', {tagName: 'p'}, [])),
u('element', {tagName: 'p'}, []),
'should reset parent nodes (1)'
);

t.deepEqual(
fromString(u('element', {tagName: 'p'}, [u('text', 'foo')])),
u('element', {tagName: 'p'}, []),
'should reset parent nodes (2)'
);

t.end();
});
47 changes: 47 additions & 0 deletions packages/hast-util-is-body-ok-link/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @fileoverview
* Check if a `link` element is “Body OK”.
*/

'use strict';

var is = require('hast-util-is-element');
var has = require('hast-util-has-property');

module.exports = ok;

var list = [
'pingback',
'prefetch',
'stylesheet'
];

function ok(node) {
var length;
var index;
var rel;

if (!is(node, 'link')) {
return false;
}

if (has(node, 'itemProp')) {
return true;
}

rel = (node.properties || {}).rel || [];
length = rel.length;
index = -1;

if (!rel.length) {
return false;
}

while (++index < length) {
if (list.indexOf(rel[index]) === -1) {
return false;
}
}

return true;
}
26 changes: 26 additions & 0 deletions packages/hast-util-is-body-ok-link/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "hast-util-is-body-ok-link",
"version": "0.0.0",
"description": "Check if a link element is “Body OK”",
"license": "MIT",
"keywords": [
"rehype",
"hast",
"link",
"body",
"ok"
],
"repository": "https://github.com/wooorm/rehype-minify/tree/master/packages/hast-util-is-body-ok-link",
"bugs": "https://github.com/wooorm/rehype-minify/issues",
"author": "Titus Wormer <[email protected]> (http://wooorm.com)",
"contributors": [
"Titus Wormer <[email protected]>"
],
"files": [
"index.js"
],
"dependencies": {
"hast-util-has-property": "^1.0.0",
"hast-util-is-element": "^1.0.0"
}
}
15 changes: 15 additions & 0 deletions packages/hast-util-is-body-ok-link/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--This file is generated by `build-packages.js`-->

# hast-util-is-body-ok-link

Check if a `link` element is “Body OK”.

## Install

```sh
npm install hast-util-is-body-ok-link
```

## License

[MIT](https://github.com/wooorm/rehype-minify/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
Loading

0 comments on commit 1c6eba7

Please sign in to comment.