Importing assets

pull/1/head
Oliver Kennedy 2015-12-03 19:57:30 -05:00
parent b3484de191
commit 810711a880
1510 changed files with 214970 additions and 10 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
assets/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

BIN
assets/logos/.DS_Store vendored Normal file

Binary file not shown.

BIN
assets/logos/ASTral.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
assets/logos/BlackHat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
assets/logos/PocketData.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
assets/people/oliver.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

View File

@ -10,6 +10,9 @@ var metadata = require('metalsmith-metadata');
var fingerprint = require('metalsmith-fingerprint');
var branch = require('metalsmith-branch');
var assets = require('metalsmith-assets');
var paths = require('metalsmith-paths');
var linkchecker = require('metalsmith-broken-link-checker');
var rootpath = require('metalsmith-rootpath');
/**
* Build.
@ -28,13 +31,21 @@ var metalsmith = Metalsmith(__dirname)
source: './assets',
destination: './assets'
}))
.use( branch()
.pattern('*.html')
.use(paths({
property: "paths"
}))
.use(rootpath())
.use(branch()
.pattern('**/*.html')
.use(layouts({
engine: "handlebars",
default: "default.hbs"
}))
)
.use(linkchecker({
allowRegex: /^(\/resources|\/slides)/,
allowRedirect: true
}))
// .use(uglify())
.build(function(err){
if (err) throw err;

View File

@ -5,29 +5,29 @@
<title>The ODIn Lab: {{ title }}</title>
{{! Files will be fingerprinted for cache busting }}
{{! Access their filenames with the fingerprint variable }}
<link rel="stylesheet" href="{{ fingerprint.[css/index.css] }}">
<link rel="stylesheet" href="{{{rootPath}}}{{ fingerprint.[css/index.css] }}">
</head>
<body>
<div class="header_logo">
<div class="segment">
<a href="http://www.buffalo.edu">
<img src="assets/logos/ub_logo_1line_white.png"
<img src="{{{rootPath}}}assets/logos/ub_logo_1line_white.png"
height="20"
style="float: left; margin-top:8px"
/></a>
<a href="/index.html">
<img src="assets/logos/lab_logo_1line_white.png"
<img src="{{{rootPath}}}assets/logos/lab_logo_1line_white.png"
height="35"
style="float: right"/></a>
</div>
</div>
<div class="header_menu">
<li class="first"><a href="/people.html">People</a></li>
<li><a href="/projects.html">Projects</a></li>
<li><a href="/teaching.html">Teaching</a></li>
<li><a href="/pubs.html">Publications</a></li>
<li><a href="/grants.html">Funding</a></li>
<li class="first"><a href="{{{rootPath}}}people.html">People</a></li>
<li><a href="{{{rootPath}}}projects/index.html">Projects</a></li>
<li><a href="{{{rootPath}}}teaching/index.html">Teaching</a></li>
<li><a href="{{{rootPath}}}pubs.html">Publications</a></li>
<li><a href="{{{rootPath}}}grants.html">Funding</a></li>
<li><a href="http://gitlab.odin.cse.buffalo.edu/odin-lab/documentation/wikis/home">Wiki</a></li>
</div>

10
node_modules/boolbase/README.md generated vendored Normal file
View File

@ -0,0 +1,10 @@
#boolbase
This very simple module provides two basic functions, one that always returns true (`trueFunc`) and one that always returns false (`falseFunc`).
###WTF?
By having only a single instance of these functions around, it's possible to do some nice optimizations. Eg. [`CSSselect`](https://github.com/fb55/CSSselect) uses these functions to determine whether a selector won't match any elements. If that's the case, the DOM doesn't even have to be touched.
###And why is this a separate module?
I'm trying to modularize `CSSselect` and most modules depend on these functions. IMHO, having a separate module is the easiest solution to this problem.

8
node_modules/boolbase/index.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
trueFunc: function trueFunc(){
return true;
},
falseFunc: function falseFunc(){
return false;
}
};

75
node_modules/boolbase/package.json generated vendored Normal file
View File

@ -0,0 +1,75 @@
{
"_args": [
[
"boolbase@~1.0.0",
"/Users/okennedy/Documents/Website/node_modules/css-select"
]
],
"_from": "boolbase@>=1.0.0 <1.1.0",
"_id": "boolbase@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/boolbase",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "1.4.2",
"_phantomChildren": {},
"_requested": {
"name": "boolbase",
"raw": "boolbase@~1.0.0",
"rawSpec": "~1.0.0",
"scope": null,
"spec": ">=1.0.0 <1.1.0",
"type": "range"
},
"_requiredBy": [
"/css-select",
"/nth-check"
],
"_resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"_shasum": "68dff5fbe60c51eb37725ea9e3ed310dcc1e776e",
"_shrinkwrap": null,
"_spec": "boolbase@~1.0.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/css-select",
"author": {
"email": "me@feedic.com",
"name": "Felix Boehm"
},
"bugs": {
"url": "https://github.com/fb55/boolbase/issues"
},
"dependencies": {},
"description": "two functions: One that returns true, one that returns false",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "68dff5fbe60c51eb37725ea9e3ed310dcc1e776e",
"tarball": "http://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz"
},
"homepage": "https://github.com/fb55/boolbase",
"keywords": [
"boolean",
"function"
],
"license": "ISC",
"main": "index.js",
"maintainers": [
{
"name": "feedic",
"email": "me@feedic.com"
}
],
"name": "boolbase",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/fb55/boolbase.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.0"
}

10
node_modules/cheerio/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,10 @@
{
"indent": 2,
"eqnull": true,
"laxbreak": true,
"proto": true,
"undef": true,
"unused": true,
"node": true,
"quotmark": "single"
}

9
node_modules/cheerio/.npmignore generated vendored Normal file
View File

@ -0,0 +1,9 @@
benchmark/
src/
support/
tests/
examples/
*.sock
*.tmproj
coverage.html
lib-cov

9
node_modules/cheerio/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,9 @@
language: node_js
node_js:
- "0.10"
- 0.11
script: make travis-test
matrix:
fast_finish: true
allow_failures:
- node_js: 0.11

47
node_modules/cheerio/CONTRIBUTING.md generated vendored Normal file
View File

@ -0,0 +1,47 @@
# Contributing to Cheerio
Thanks for your interest in contributing to the project! Here's a rundown of
how we'd like to work with you:
1. File an issue on GitHub describing the contribution you'd like to make. This
will help us to get you started on the right foot.
2. Create a single commit that addresses the issue:
1. Follow the project's code style (see below)
2. Add enough unit tests to "prove" that your patch is correct
3. Update the project documentation as needed (see below)
4. Describe your approach with as much detail as necessary in the git
commit message
3. Open a pull request, and reference the initial issue in the pull request
message.
# Documentation
Any API change should be reflected in the project's README.md file. Reuse
[jQuery's documentation](http://api.jquery.com) wherever possible, but take
care to note aspects that make Cheerio distinct.
# Code Style
This section is by no means complete. For undocumented stylistic choices,
please try to maintain consistency with the code base.
- Single quotes: `'`
- Whitespace
- Two-space "soft" tabs
- Once space following control flow statements (`if (condition) {` rather
than `if(condition) {`)
- Remove trailing spaces
- [End each file with a newline
character.](https://github.com/editorconfig/editorconfig/wiki/Newline-at-End-of-File-Support)
- Terminate every statement with a semicolon
- Private functionality (for re-using functionality that isn't part of the
jQuery API)
- *Static methods*: If the functionality does not require a reference to a
Cheerio instance, simply define a named function within the module it is
needed.
- *Instance methods*: If the functionality requires a reference to a Cheerio
instance, informally define the method as "private" using the following
conventions:
- Define the method as a function on the Cheerio prototype
- Prefix the method name with an underscore (`_`) character
- Include `@api private` in the code comment the documents the method

515
node_modules/cheerio/History.md generated vendored Normal file
View File

@ -0,0 +1,515 @@
0.19.0 / 2015-03-21
==================
* fixed allignment (fb55)
* added test case for malformed json in data attributes (fb55)
* fix: handle some extreme cases like `data-custom="{{templatevar}}"`. There is possibility error while parsing json . (Harish.K)
* Add missing optional selector doc for {prev,next}{All,Until} (Jérémie Astori)
* update to dom-serializer@0.1.0 (Felix Böhm)
* Document `Cheerio#serialzeArray` (Mike Pennisi)
* Fixed up `serializeArray()` and added multiple support (Todd Wolfson)
* Implement serializeArray() (Jarno Leppänen)
* recognize options in $.xml() (fb55)
* lib/static.js: text(): rm errant space before ++ (Chris Rebert)
* Do not expose internal `children` array (Mike Pennisi)
* Change lodash dependencies to ^3.1.0 (Samy Pessé)
* Update lodash@3.1.0 (Samy Pessé)
* Updates Readme.md: .not(function (index, elem)) (Patrick Ward)
* update to css-select@1.0.0 (fb55)
* Allow failures in Node.js v0.11 (Mike Pennisi)
* Added: Gittask badge (Matthew Mueller)
* Isolate prototypes of functions created via `load` (Mike Pennisi)
* Updates Readme.md: adds JS syntax highlighting (frankcash)
* #608 -- Add support for insertBefore/insertAfter syntax. Supports target types of: $, [$], selector (both single and multiple results) (Ben Cochran)
* Clone input nodes when inserting over a set (Mike Pennisi)
* Move unit test files (Mike Pennisi)
* remove unnecessarily tricky code (David Chambers)
* pass options to $.html in toString (fb55)
* add license info to package.json (Chris Rebert)
* xyz@~0.5.0 (David Chambers)
* Remove unofficial signature of `children` (Mike Pennisi)
* Fix bug in `css` method (Mike Pennisi)
* Correct bug in implementation of `Cheerio#val` (Mike Pennisi)
0.18.0 / 2014-11-06
==================
* bump htmlparser2 dependency to ~3.8.1 (Chris Rebert)
* Correct unit test titles (Mike Pennisi)
* Correct behavior of `after` and `before` (Mike Pennisi)
* implement jQuery's .has() (Chris Rebert)
* Update repository url (haqii)
* attr() should return undefined or name for booleans (Raoul Millais)
* Update Readme.md (Ryan Breen)
* Implement `Cheerio#not` (Mike Pennisi)
* Clone nodes according to original parsing options (Mike Pennisi)
* fix lint error (David Chambers)
* Add explicit tests for DOM level 1 API (Mike Pennisi)
* Expose DOM level 1 API for Node-like objects (Mike Pennisi)
* Correct error in documentation (Mike Pennisi)
* Return a fully-qualified Function from `$.load` (Mike Pennisi)
* Update tests to avoid duck typing (Mike Pennisi)
* Alter "loaded" functions to produce true instances (Mike Pennisi)
* Organize tests for `cheerio.load` (Mike Pennisi)
* Complete `$.prototype.find` (Mike Pennisi)
* Use JSHint's `extends` option (Mike Pennisi)
* Remove aliases for exported methods (Mike Pennisi)
* Disallow unused variables (Mike Pennisi)
* Remove unused internal variables (Mike Pennisi)
* Remove unused variables from unit tests (Mike Pennisi)
* Remove unused API method references (Mike Pennisi)
* Move tests for `contains` method (Mike Pennisi)
* xyz@0.4.0 (David Chambers)
* Created a wiki for companies using cheerio in production (Matthew Mueller)
* Implement `$.prototype.index` (Mike Pennisi)
* Implement `$.prototype.addBack` (Mike Pennisi)
* Added double quotes to radio attribute name to account for characters such as brackets (akant10)
* Update History.md (Gabriel Falkenberg)
* add 0.17.0 changelog (David Chambers)
* exit prepublish script if tag not found (David Chambers)
* alphabetize devDependencies (fb55)
* ignore coverage dir (fb55)
* submit coverage to coveralls (fb55)
* replace jscoverage with istanbul (fb55)
0.17.0 / 2014-06-10
==================
* Fix bug in internal `uniqueSplice` function (Mike Pennisi)
* accept buffer argument to cheerio.load (David Chambers)
* Respect options on the element level (Alex Indigo)
* Change state definition to more readable (Artem Burtsev)
* added test (0xBADC0FFEE)
* add class only if doesn't exist (Artem Burtsev)
* Made it less insane. (Alex Indigo)
* Implement `Cheerio#add` (Mike Pennisi)
* Use "loaded" instance of Cheerio in unit tests (Mike Pennisi)
* Be more strict with object check. (Alex Indigo)
* Added options argument to .html() static method. (Alex Indigo)
* Fixed encoding mishaps. Adjusted tests. (Alex Indigo)
* use dom-serializer module (fb55)
* don't test on 0.8, don't ignore 0.11 (Felix Böhm)
* parse: rm unused variables (coderaiser)
* cheerio: rm unused variable (coderaiser)
* Fixed test (Avi Kohn)
* Added test (Avi Kohn)
* Changed == to === (Avi Kohn)
* Fixed a bug in removing type="hidden" attr (Avi Kohn)
* sorted (Alexey Raspopov)
* add `muted` attr to booleanAttributes (Alexey Raspopov)
* fixed context of `this` in .html (Felix Böhm)
* append new elements for each element in selection (fb55)
0.16.0 / 2014-05-08
==================
* fix `make bench` (David Chambers)
* makefile: add release-* targets (David Chambers)
* alphabetize dependencies (David Chambers)
* Rewrite `data` internals with caching behavior (Mike Pennisi)
* Fence .val example as js (Kevin Sawicki)
* Fixed typos. Deleted trailing whitespace from test/render.js (Nattaphoom Ch)
* Fix manipulation APIs with removed elements (kpdecker)
* Perform manual string parsing for hasClass (kpdecker)
* Fix existing element removal (kpdecker)
* update render tests (Felix Böhm)
* fixed cheerio path (Felix Böhm)
* use `entities.escape` for attribute values (Felix Böhm)
* bump entities version (Felix Böhm)
* remove lowerCaseTags option from readme (Felix Böhm)
* added test case for .html in xmlMode (fb55)
* render xml in `html()` when `xmlMode: true` (fb55)
* use a map for booleanAttributes (fb55)
* update singleTags, use utils.isTag (fb55)
* update travis badge URL (Felix Böhm)
* use typeof instead of _.isString and _.isNumber (fb55)
* use Array.isArray instead of _.isArray (fb55)
* replace _.isFunction with typeof (fb55)
* removed unnecessary error message (fb55)
* decode entities in htmlparser2 (fb55)
* pass options object to CSSselect (fb55)
0.15.0 / 2014-04-08
==================
* Update callbacks to pass element per docs (@kpdecker)
* preserve options (@fb55)
* Use SVG travis badge (@t3chnoboy)
* only use static requires (@fb55)
* Optimize manipulation methods (@kpdecker)
* Optimize add and remove class cases (@kpdecker)
* accept dom of DomHandler to cheerio.load (@nleush)
* added parentsUntil method (@finspin)
* Add performance optimization and bug fix `empty` method (@kpdecker)
0.14.0 / 2014-04-01
==================
* call encodeXML and directly expose decodeHTML (@fb55)
* use latest htmlparser2 and entities versions (@fb55)
* Deprecate `$.fn.toArray` (@jugglinmike)
* Implement `$.fn.get` (@jugglinmike)
* .replaceWith now replaces all selected elements. (@xavi-)
* Correct arguments for 'replaceWith' callback (@jugglinmike)
* switch to lodash (@fb55)
* update to entities@0.5.0 (@fb55)
* Fix attr when $ collection contains text modules (@kpdecker)
* Update to latest version of expect.js (@jugglinmike)
* Remove nodes from their previous structures (@jugglinmike)
* Update render.js (@stevenvachon)
* CDATA test (@stevenvachon)
* only ever one child index for cdata (@stevenvachon)
* don't loop through cdata children array (@stevenvachon)
* proper rendering of CDATA (@stevenvachon)
* Add cheerio-only bench option (@kpdecker)
* Avoid delete operations (@kpdecker)
* Add independent html benchmark (@kpdecker)
* Cache tag check in render (@kpdecker)
* Simplify attribute rendering step (@kpdecker)
* Add html rendering bench case (@kpdecker)
* Remove unnecessary check from removeAttr (@kpdecker)
* Remove unnecessary encoding step for attrs (@kpdecker)
* Add test for removeAttr+attr on boolean attributes (@kpdecker)
* Add single element benchmark case (@kpdecker)
* Optimize filter with selector (@kpdecker)
* Fix passing context as dom node (@alfred-nsh)
* Fix bug in `nextUntil` (@jugglinmike)
* Fix bug in `nextAll` (@jugglinmike)
* Implement `selector` argument of `next` method (@jugglinmike)
* Fix bug in `prevUntil` (@jugglinmike)
* Implement `selector` argument of `prev` method (@jugglinmike)
* Fix bug in `prevAll` (@jugglinmike)
* Fix bug in `siblings` (@jugglinmike)
* Avoid unnecessary indexOf from toggleClass (@kpdecker)
* Use strict equality rather than falsy check in eq (@kpdecker)
* Add benchmark coverage for all $ APIs (@kpdecker)
* Optimize filter Cheerio intermediate creation (@kpdecker)
* Optimize siblings cheerio instance creation (@kpdecker)
* Optimize identity cases for first/last/eq (@kpdecker)
* Use domEach for traversal (@kpdecker)
* Inline children lookup in find (@kpdecker)
* Use domEach in data accessor (@kpdecker)
* Avoid cheerio creation in add/remove/toggleClass (@kpdecker)
* Implement getAttr local helper (@kpdecker)
0.13.1 / 2014-01-07
==================
* Fix select with context in Cheerio function (@jugglinmike)
* Remove unecessary DOM maintenance logic (@jugglinmike)
* Deprecate support for node 0.6
0.13.0 / 2013-12-30
==================
* Remove "root" node (@jugglinmike)
* Fix bug in `prevAll`, `prev`, `nextAll`, `next`, `prevUntil`, `nextUntil` (@jugglinmike)
* Fix `replaceWith` method (@jugglinmike)
* added nextUntil() and prevUntil() (@finspin)
* Remove internal `connect` function (@jugglinmike)
* Rename `Cheerio#make` to document private status (@jugginmike)
* Remove extraneous call to `_.uniq` (@jugglinmike)
* Use CSSselect library directly (@jugglinmike)
* Run CI against Node v0.11 as an allowed failure (@jugginmike)
* Correct bug in `Cheerio#parents` (@jugglinmike)
* Implement `$.fn.end` (@jugginmike)
* Ignore colons inside of url(.*) when parsing css (@Meekohi)
* Introduce rudimentary benchmark suite (@jugglinmike)
* Update HtmlParser2 version (@jugglinmike)
* Correct inconsistency in `$.fn.map` (@jugglinmike)
* fixed traversing tests (@finspin)
* Simplify `make` method (@jugglinmike)
* Avoid shadowing instance methods from arrays (@jugglinmike)
0.12.4 / 2013-11-12
==================
* Coerce JSON values returned by `data` (@jugglinmike)
* issue #284: when rendering HTML, use original data attributes (@Trott)
* Introduce JSHint for automated code linting (@jugglinmike)
* Prevent `find` from returning duplicate elements (@jugglinmike)
* Implement function signature of `replaceWith` (@jugglinmike)
* Implement function signature of `before` (@jugglinmike)
* Implement function signature of `after` (@jugglinmike)
* Implement function signature of `append`/`prepend` (@jugglinmike)
* Extend iteration methods to accept nodes (@jugglinmike)
* Improve `removeClass` (@jugglinmike)
* Complete function signature of `addClass` (@jugglinmike)
* Fix bug in `removeClass` (@jugglinmike)
* Improve contributing.md (@jugglinmike)
* Fix and document .css() (@jugglinmike)
0.12.3 / 2013-10-04
===================
* Add .toggleClass() function (@cyberthom)
* Add contributing guidelines (@jugglinmike)
* Fix bug in `siblings` (@jugglinmike)
* Correct the implementation `filter` and `is` (@jugglinmike)
* add .data() function (@andi-neck)
* add .css() (@yields)
* Implements contents() (@jlep)
0.12.2 / 2013-09-04
==================
* Correct implementation of `$.fn.text` (@jugglinmike)
* Refactor Cheerio array creation (@jugglinmike)
* Extend manipulation methods to accept Arrays (@jugglinmike)
* support .attr(attributeName, function(index, attr)) (@xiaohwan)
0.12.1 / 2013-07-30
==================
* Correct behavior of `Cheerio#parents` (@jugglinmike)
* Double quotes inside attributes kills HTML (@khoomeister)
* Making next({}) and prev({}) return empty object (@absentTelegraph)
* Implement $.parseHTML (@jugglinmike)
* Correct bug in jQuery.fn.closest (@jugglinmike)
* Correct behavior of $.fn.val on 'option' elements (@jugglinmike)
0.12.0 / 2013-06-09
===================
* Breaking Change: Changed context from parent to the actual passed one (@swissmanu)
* Fixed: jquery checkbox val behavior (@jhubble)
* Added: output xml with $.xml() (@Maciek416)
* Bumped: htmlparser2 to 3.1.1
* Fixed: bug in attr(key, val) on empty objects (@farhadi)
* Added: prevAll, nextAll (@lessmind)
* Fixed: Safety check in parents and closest (@zero21xxx)
* Added: .is(sel) (@zero21xxx)
0.11.0 / 2013-04-22
==================
* Added: .closest() (@jeremy-dentel)
* Added: .parents() (@zero21xxx)
* Added: .val() (@rschmukler & @leahciMic)
* Added: Travis support for node 0.10.0 (@jeremy-dentel)
* Fixed: .find() if no selector (@davidchambers)
* Fixed: Propagate syntax errors caused by invalid selectors (@davidchambers)
0.10.8 / 2013-03-11
==================
* Add slice method (SBoudrias)
0.10.7 / 2013-02-10
==================
* Code & doc cleanup (davidchambers)
* Fixed bug in filter (jugglinmike)
0.10.6 / 2013-01-29
==================
* Added `$.contains(...)` (jugglinmike)
* formatting cleanup (davidchambers)
* Bug fix for `.children()` (jugglinmike & davidchambers)
* Remove global `render` bug (wvl)
0.10.5 / 2012-12-18
===================
* Fixed botched publish from 0.10.4 - changes should now be present
0.10.4 / 2012-12-16
==================
* $.find should query descendants only (@jugglinmike)
* Tighter underscore dependency
0.10.3 / 2012-11-18
===================
* fixed outer html bug
* Updated documentation for $(...).html() and $.html()
0.10.2 / 2012-11-17
===================
* Added a toString() method (@bensheldon)
* use `_.each` and `_.map` to simplify cheerio namesakes (@davidchambers)
* Added filter() with tests and updated readme (@bensheldon & @davidchambers)
* Added spaces between attributes rewritten by removeClass (@jos3000)
* updated docs to remove reference to size method (@ironchefpython)
* removed HTML tidy/pretty print from cheerio
0.10.1 / 2012-10-04
===================
* Fixed regression, filtering with a context (#106)
0.10.0 / 2012-09-24
===================
* Greatly simplified and reorganized the library, reducing the loc by 30%
* Now supports mocha's test-coverage
* Deprecated self-closing tags (HTML5 doesn't require them)
* Fixed error thrown in removeClass(...) @robashton
0.9.2 / 2012-08-10
==================
* added $(...).map(fn)
* manipulation: refactor `makeCheerioArray`
* make .removeClass() remove *all* occurrences (#64)
0.9.1 / 2012-08-03
==================
* fixed bug causing options not to make it to the parser
0.9.0 / 2012-07-24
==================
* Added node 8.x support
* Removed node 4.x support
* Add html(dom) support (@wvl)
* fixed xss vulnerabilities on .attr(), .text(), & .html() (@benatkin, @FB55)
* Rewrote tests into javascript, removing coffeescript dependency (@davidchambers)
* Tons of cleanup (@davidchambers)
0.8.3 / 2012-06-12
==================
* Fixed minor package regression (closes #60)
0.8.2 / 2012-06-11
==================
* Now fails gracefully in cases that involve special chars, which is inline with jQuery (closes #59)
* text() now decode special entities (closes #52)
* updated travis.yml to test node 4.x
0.8.1 / 2012-06-02
==================
* fixed regression where if you created an element, it would update the root
* compatible with node 4.x (again)
0.8.0 / 2012-05-27
==================
* Updated CSS parser to use FB55/CSSselect. Cheerio now supports most CSS3 psuedo selectors thanks to @FB55.
* ignoreWhitespace now on by default again. See #55 for context.
* Changed $(':root') to $.root(), cleaned up $.clone()
* Support for .eq(i) thanks to @alexbardas
* Removed support for node 0.4.x
* Fixed memory leak where package.json was continually loaded
* Tons more tests
0.7.0 / 2012-04-08
==================
* Now testing with node v0.7.7
* Added travis-ci integration
* Replaced should.js with expect.js. Browser testing to come
* Fixed spacing between attributes and their values
* Added HTML tidy/pretty print
* Exposed node-htmlparser2 parsing options
* Revert .replaceWith(...) to be consistent with jQuery
0.6.2 / 2012-02-12
==================
* Fixed .replaceWith(...) regression
0.6.1 / 2012-02-12
==================
* Added .first(), .last(), and .clone() commands.
* Option to parse using whitespace added to `.load`.
* Many bug fixes to make cheerio more aligned with jQuery.
* Added $(':root') to select the highest level element.
Many thanks to the contributors that made this release happen: @ironchefpython and @siddMahen
0.6.0 / 2012-02-07
==================
* *Important:* `$(...).html()` now returns inner HTML, which is in line with the jQuery spec
* `$.html()` returns the full HTML string. `$.html([cheerioObject])` will return the outer(selected element's tag) and inner HTML of that object
* Fixed bug that prevented HTML strings with depth (eg. `append('<ul><li><li></ul>')`) from getting `parent`, `next`, `prev` attributes.
* Halted [htmlparser2](https://github.com/FB55/node-htmlparser) at v2.2.2 until single attributes bug gets fixed.
0.5.1 / 2012-02-05
==================
* Fixed minor regression: $(...).text(fn) would fail
0.5.1 / 2012-02-05
==================
* Fixed regression: HTML pages with comments would fail
0.5.0 / 2012-02-04
==================
* Transitioned from Coffeescript back to Javascript
* Parser now ignores whitespace
* Fixed issue with double slashes on self-enclosing tags
* Added boolean attributes to html rendering
0.4.2 / 2012-01-16
==================
* Multiple selectors support: $('.apple, .orange'). Thanks @siddMahen!
* Update package.json to always use latest cheerio-soupselect
* Fix memory leak in index.js
0.4.1 / 2011-12-19
==================
* Minor packaging changes to allow `make test` to work from npm installation
0.4.0 / 2011-12-19
==================
* Rewrote all unit tests as cheerio transitioned from vows -> mocha
* Internally, renderer.render -> render(...), parser.parse -> parse(...)
* Append, prepend, html, before, after all work with only text (no tags)
* Bugfix: Attributes can now be removed from script and style tags
* Added yield as a single tag
* Cheerio now compatible with node >=0.4.7
0.3.2 / 2011-12-1
=================
* Fixed $(...).text(...) to work with "root" element
0.3.1 / 2011-11-25
==================
* Now relying on cheerio-soupselect instead of node-soupselect
* Removed all lingering htmlparser dependencies
* parser now returns parent "root" element. Root now never needs to be updated when there is multiple roots. This fixes ongoing issues with before(...), after(...) and other manipulation functions
* Added jQuery's $(...).replaceWith(...)
0.3.0 / 2011-11-19
==================
* Now using htmlparser2 for parsing (2x speed increase, cleaner, actively developed)
* Added benchmark directory for future speed tests
* $('...').dom() was funky, so it was removed in favor of $('...').get(). $.dom() still works the same.
* $.root now correctly static across all instances of $
* Added a screencast
0.2.2 / 2011-11-9
=================
* Traversing will select `<script>` and `<style>` tags (Closes Issue: #8)
* .text(string) now working with empty elements (Closes Issue: #7)
* Fixed before(...) & after(...) again if there is no parent (Closes Issue: #2)
0.2.1 / 2011-11-5
=================
* Fixed before(...) & after(...) if there is no parent (Closes Issue: #2)
* Comments now rendered correctly (Closes Issue: #5)
< 0.2.0 / 2011-10-31
====================
* Initial release (untracked development)

36
node_modules/cheerio/Makefile generated vendored Normal file
View File

@ -0,0 +1,36 @@
REPORTER = dot
XYZ = node_modules/.bin/xyz --message 'Release X.Y.Z' --tag X.Y.Z --repo git@github.com:cheeriojs/cheerio.git --script scripts/prepublish
lint:
@./node_modules/.bin/jshint lib/ test/
test: lint
@./node_modules/.bin/mocha --recursive --reporter $(REPORTER)
setup:
@npm install
subl:
@subl lib/ test/ package.json index.js
test-cov:
@./node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --recursive --reporter $(REPORTER)
report-cov: test-cov
@cat coverage/lcov.info | ./node_modules/.bin/coveralls
travis-test: lint
@make report-cov || echo "Couldn't submit"
bench:
@./benchmark/benchmark.js
.PHONY: release-major release-minor release-patch
release-major: LEVEL = major
release-minor: LEVEL = minor
release-patch: LEVEL = patch
release-major release-minor release-patch:
@$(XYZ) --increment $(LEVEL)
.PHONY: test build setup subl

932
node_modules/cheerio/Readme.md generated vendored Normal file
View File

@ -0,0 +1,932 @@
# cheerio [![Build Status](https://secure.travis-ci.org/cheeriojs/cheerio.svg?branch=master)](http://travis-ci.org/cheeriojs/cheerio) [![Gittask](https://gittask.com/cheeriojs/cheerio.svg)](https://gittask.com/cheeriojs/cheerio)
Fast, flexible, and lean implementation of core jQuery designed specifically for the server.
## Introduction
Teach your server HTML.
```js
var cheerio = require('cheerio'),
$ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
$.html();
//=> <h2 class="title welcome">Hello there!</h2>
```
## Installation
`npm install cheerio`
## Features
__&#10084; Familiar syntax:__
Cheerio implements a subset of core jQuery. Cheerio removes all the DOM inconsistencies and browser cruft from the jQuery library, revealing its truly gorgeous API.
__&#991; Blazingly fast:__
Cheerio works with a very simple, consistent DOM model. As a result parsing, manipulating, and rendering are incredibly efficient. Preliminary end-to-end benchmarks suggest that cheerio is about __8x__ faster than JSDOM.
__&#10049; Incredibly flexible:__
Cheerio wraps around @FB55's forgiving [htmlparser2](https://github.com/fb55/htmlparser2/). Cheerio can parse nearly any HTML or XML document.
## What about JSDOM?
I wrote cheerio because I found myself increasingly frustrated with JSDOM. For me, there were three main sticking points that I kept running into again and again:
__&#8226; JSDOM's built-in parser is too strict:__
JSDOM's bundled HTML parser cannot handle many popular sites out there today.
__&#8226; JSDOM is too slow:__
Parsing big websites with JSDOM has a noticeable delay.
__&#8226; JSDOM feels too heavy:__
The goal of JSDOM is to provide an identical DOM environment as what we see in the browser. I never really needed all this, I just wanted a simple, familiar way to do HTML manipulation.
## When I would use JSDOM
Cheerio will not solve all your problems. I would still use JSDOM if I needed to work in a browser-like environment on the server, particularly if I wanted to automate functional tests.
## API
### Markup example we'll be using:
```html
<ul id="fruits">
<li class="apple">Apple</li>
<li class="orange">Orange</li>
<li class="pear">Pear</li>
</ul>
```
This is the HTML markup we will be using in all of the API examples.
### Loading
First you need to load in the HTML. This step in jQuery is implicit, since jQuery operates on the one, baked-in DOM. With Cheerio, we need to pass in the HTML document.
This is the _preferred_ method:
```js
var cheerio = require('cheerio'),
$ = cheerio.load('<ul id="fruits">...</ul>');
```
Optionally, you can also load in the HTML by passing the string as the context:
```js
$ = require('cheerio');
$('ul', '<ul id="fruits">...</ul>');
```
Or as the root:
```js
$ = require('cheerio');
$('li', 'ul', '<ul id="fruits">...</ul>');
```
You can also pass an extra object to `.load()` if you need to modify any
of the default parsing options:
```js
$ = cheerio.load('<ul id="fruits">...</ul>', {
normalizeWhitespace: true,
xmlMode: true
});
```
These parsing options are taken directly from [htmlparser2](https://github.com/fb55/htmlparser2/wiki/Parser-options), therefore any options that can be used in `htmlparser2` are valid in cheerio as well. The default options are:
```js
{
normalizeWhitespace: false,
xmlMode: false,
decodeEntities: true
}
```
For a full list of options and their effects, see [this](https://github.com/fb55/DomHandler) and
[htmlparser2's options](https://github.com/fb55/htmlparser2/wiki/Parser-options).
### Selectors
Cheerio's selector implementation is nearly identical to jQuery's, so the API is very similar.
#### $( selector, [context], [root] )
`selector` searches within the `context` scope which searches within the `root` scope. `selector` and `context` can be an string expression, DOM Element, array of DOM elements, or cheerio object. `root` is typically the HTML document string.
This selector method is the starting point for traversing and manipulating the document. Like jQuery, it's the primary method for selecting elements in the document, but unlike jQuery it's built on top of the CSSSelect library, which implements most of the Sizzle selectors.
```js
$('.apple', '#fruits').text()
//=> Apple
$('ul .pear').attr('class')
//=> pear
$('li[class=orange]').html()
//=> <li class="orange">Orange</li>
```
### Attributes
Methods for getting and modifying attributes.
#### .attr( name, value )
Method for getting and setting attributes. Gets the attribute value for only the first element in the matched set. If you set an attribute's value to `null`, you remove that attribute. You may also pass a `map` and `function` like jQuery.
```js
$('ul').attr('id')
//=> fruits
$('.apple').attr('id', 'favorite').html()
//=> <li class="apple" id="favorite">Apple</li>
```
> See http://api.jquery.com/attr/ for more information
#### .data( name, value )
Method for getting and setting data attributes. Gets or sets the data attribute value for only the first element in the matched set.
```js
$('<div data-apple-color="red"></div>').data()
//=> { appleColor: 'red' }
$('<div data-apple-color="red"></div>').data('data-apple-color')
//=> 'red'
var apple = $('.apple').data('kind', 'mac')
apple.data('kind')
//=> 'mac'
```
> See http://api.jquery.com/data/ for more information
#### .val( [value] )
Method for getting and setting the value of input, select, and textarea. Note: Support for `map`, and `function` has not been added yet.
```js
$('input[type="text"]').val()
//=> input_text
$('input[type="text"]').val('test').html()
//=> <input type="text" value="test"/>
```
#### .removeAttr( name )
Method for removing attributes by `name`.
```js
$('.pear').removeAttr('class').html()
//=> <li>Pear</li>
```
#### .hasClass( className )
Check to see if *any* of the matched elements have the given `className`.
```js
$('.pear').hasClass('pear')
//=> true
$('apple').hasClass('fruit')
//=> false
$('li').hasClass('pear')
//=> true
```
#### .addClass( className )
Adds class(es) to all of the matched elements. Also accepts a `function` like jQuery.
```js
$('.pear').addClass('fruit').html()
//=> <li class="pear fruit">Pear</li>
$('.apple').addClass('fruit red').html()
//=> <li class="apple fruit red">Apple</li>
```
> See http://api.jquery.com/addClass/ for more information.
#### .removeClass( [className] )
Removes one or more space-separated classes from the selected elements. If no `className` is defined, all classes will be removed. Also accepts a `function` like jQuery.
```js
$('.pear').removeClass('pear').html()
//=> <li class="">Pear</li>
$('.apple').addClass('red').removeClass().html()
//=> <li class="">Apple</li>
```
> See http://api.jquery.com/removeClass/ for more information.
#### .toggleClass( className, [switch] )
Add or remove class(es) from the matched elements, depending on either the class's presence or the value of the switch argument. Also accepts a `function` like jQuery.
```js
$('.apple.green').toggleClass('fruit green red').html()
//=> <li class="apple fruit red">Apple</li>
$('.apple.green').toggleClass('fruit green red', true).html()
//=> <li class="apple green fruit red">Apple</li>
```
> See http://api.jquery.com/toggleClass/ for more information.
#### .is( selector )
#### .is( element )
#### .is( selection )
#### .is( function(index) )
Checks the current list of elements and returns `true` if _any_ of the elements match the selector. If using an element or Cheerio selection, returns `true` if _any_ of the elements match. If using a predicate function, the function is executed in the context of the selected element, so `this` refers to the current element.
### Forms
#### .serializeArray()
Encode a set of form elements as an array of names and values.
```js
$('<form><input name="foo" value="bar" /></form>').serializeArray()
//=> [ { name: 'foo', valule: 'bar' } ]
```
### Traversing
#### .find(selector)
#### .find(selection)
#### .find(node)
Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
```js
$('#fruits').find('li').length
//=> 3
$('#fruits').find($('.apple')).length
//=> 1
```
#### .parent([selector])
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
```js
$('.pear').parent().attr('id')
//=> fruits
```
#### .parents([selector])
Get a set of parents filtered by `selector` of each element in the current set of match elements.
```js
$('.orange').parents().length
// => 2
$('.orange').parents('#fruits').length
// => 1
```
#### .parentsUntil([selector][,filter])
Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or cheerio object.
```js
$('.orange').parentsUntil('#food').length
// => 1
```
#### .closest(selector)
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
```js
$('.orange').closest()
// => []
$('.orange').closest('.apple')
// => []
$('.orange').closest('li')
// => [<li class="orange">Orange</li>]
$('.orange').closest('#fruits')
// => [<ul id="fruits"> ... </ul>]
```
#### .next([selector])
Gets the next sibling of the first selected element, optionally filtered by a selector.
```js
$('.apple').next().hasClass('orange')
//=> true
```
#### .nextAll([selector])
Gets all the following siblings of the first selected element, optionally filtered by a selector.
```js
$('.apple').nextAll()
//=> [<li class="orange">Orange</li>, <li class="pear">Pear</li>]
$('.apple').nextAll('.orange')
//=> [<li class="orange">Orange</li>]
```
#### .nextUntil([selector], [filter])
Gets all the following siblings up to but not including the element matched by the selector, optionally filtered by another selector.
```js
$('.apple').nextUntil('.pear')
//=> [<li class="orange">Orange</li>]
```
#### .prev([selector])
Gets the previous sibling of the first selected element optionally filtered by a selector.
```js
$('.orange').prev().hasClass('apple')
//=> true
```
#### .prevAll([selector])
Gets all the preceding siblings of the first selected element, optionally filtered by a selector.
```js
$('.pear').prevAll()
//=> [<li class="orange">Orange</li>, <li class="apple">Apple</li>]
$('.pear').prevAll('.orange')
//=> [<li class="orange">Orange</li>]
```
#### .prevUntil([selector], [filter])
Gets all the preceding siblings up to but not including the element matched by the selector, optionally filtered by another selector.
```js
$('.pear').prevUntil('.apple')
//=> [<li class="orange">Orange</li>]
```
#### .slice( start, [end] )
Gets the elements matching the specified range
```js
$('li').slice(1).eq(0).text()
//=> 'Orange'
$('li').slice(1, 2).length
//=> 1
```
#### .siblings( selector )
Gets the first selected element's siblings, excluding itself.
```js
$('.pear').siblings().length
//=> 2
$('.pear').siblings('.orange').length
//=> 1
```
#### .children( selector )
Gets the children of the first selected element.
```js
$('#fruits').children().length
//=> 3
$('#fruits').children('.pear').text()
//=> Pear
```
#### .contents()
Gets the children of each element in the set of matched elements, including text and comment nodes.
```js
$('#fruits').contents().length
//=> 3
```
#### .each( function(index, element) )
Iterates over a cheerio object, executing a function for each matched element. When the callback is fired, the function is fired in the context of the DOM element, so `this` refers to the current element, which is equivalent to the function parameter `element`. To break out of the `each` loop early, return with `false`.
```js
var fruits = [];
$('li').each(function(i, elem) {
fruits[i] = $(this).text();
});
fruits.join(', ');
//=> Apple, Orange, Pear
```
#### .map( function(index, element) )
Pass each element in the current matched set through a function, producing a new Cheerio object containing the return values. The function can return an individual data item or an array of data items to be inserted into the resulting set. If an array is returned, the elements inside the array are inserted into the set. If the function returns null or undefined, no element will be inserted.
```js
$('li').map(function(i, el) {
// this === el
return $(this).text();
}).get().join(' ');
//=> "apple orange pear"
```
#### .filter( selector ) <br /> .filter( selection ) <br /> .filter( element ) <br /> .filter( function(index) )
Iterates over a cheerio object, reducing the set of selector elements to those that match the selector or pass the function's test. When a Cheerio selection is specified, return only the elements contained in that selection. When an element is specified, return only that element (if it is contained in the original selection). If using the function method, the function is executed in the context of the selected element, so `this` refers to the current element.
Selector:
```js
$('li').filter('.orange').attr('class');
//=> orange
```
Function:
```js
$('li').filter(function(i, el) {
// this === el
return $(this).attr('class') === 'orange';
}).attr('class')
//=> orange
```
#### .not( selector ) <br /> .not( selection ) <br /> .not( element ) <br /> .not( function(index, elem) )
Remove elements from the set of matched elements. Given a jQuery object that represents a set of DOM elements, the `.not()` method constructs a new jQuery object from a subset of the matching elements. The supplied selector is tested against each element; the elements that don't match the selector will be included in the result. The `.not()` method can take a function as its argument in the same way that `.filter()` does. Elements for which the function returns true are excluded from the filtered set; all other elements are included.
Selector:
```js
$('li').not('.apple').length;
//=> 2
```
Function:
```js
$('li').not(function(i, el) {
// this === el
return $(this).attr('class') === 'orange';
}).length;
//=> 2
```
#### .has( selector ) <br /> .has( element )
Filters the set of matched elements to only those which have the given DOM element as a descendant or which have a descendant that matches the given selector. Equivalent to `.filter(':has(selector)')`.
Selector:
```js
$('ul').has('.pear').attr('id');
//=> fruits
```
Element:
```js
$('ul').has($('.pear')[0]).attr('id');
//=> fruits
```
#### .first()
Will select the first element of a cheerio object
```js
$('#fruits').children().first().text()
//=> Apple
```
#### .last()
Will select the last element of a cheerio object
```js
$('#fruits').children().last().text()
//=> Pear
```
#### .eq( i )
Reduce the set of matched elements to the one at the specified index. Use `.eq(-i)` to count backwards from the last selected element.
```js
$('li').eq(0).text()
//=> Apple
$('li').eq(-1).text()
//=> Pear
```
#### .get( [i] )
Retrieve the DOM elements matched by the Cheerio object. If an index is specified, retrieve one of the elements matched by the Cheerio object:
```js
$('li').get(0).tagName
//=> li
```
If no index is specified, retrieve all elements matched by the Cheerio object:
```js
$('li').get().length
//=> 3
```
#### .index()
#### .index( selector )
#### .index( nodeOrSelection )
Search for a given element from among the matched elements.
```js
$('.pear').index()
//=> 2
$('.orange').index('li')
//=> 1
$('.apple').index($('#fruit, li'))
//=> 1
```
#### .end()
End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
```js
$('li').eq(0).end().length
//=> 3
```
#### .add( selector [, context] )
#### .add( element )
#### .add( elements )
#### .add( html )
#### .add( selection )
Add elements to the set of matched elements.
```js
$('.apple').add('.orange').length
//=> 2
```
#### .addBack( [filter] )
Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
```js
$('li').eq(0).addBack('.orange').length
//=> 2
```
### Manipulation
Methods for modifying the DOM structure.
#### .append( content, [content, ...] )
Inserts content as the *last* child of each of the selected elements.
```js
$('ul').append('<li class="plum">Plum</li>')
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// <li class="plum">Plum</li>
// </ul>
```
#### .prepend( content, [content, ...] )
Inserts content as the *first* child of each of the selected elements.
```js
$('ul').prepend('<li class="plum">Plum</li>')
$.html()
//=> <ul id="fruits">
// <li class="plum">Plum</li>
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
```
#### .after( content, [content, ...] )
Insert content next to each element in the set of matched elements.
```js
$('.apple').after('<li class="plum">Plum</li>')
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="plum">Plum</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
```
#### .insertAfter( content )
Insert every element in the set of matched elements after the target.
```js
$('<li class="plum">Plum</li>').insertAfter('.apple')
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="plum">Plum</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
```
#### .before( content, [content, ...] )
Insert content previous to each element in the set of matched elements.
```js
$('.apple').before('<li class="plum">Plum</li>')
$.html()
//=> <ul id="fruits">
// <li class="plum">Plum</li>
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
```
#### .insertBefore( content )
Insert every element in the set of matched elements before the target.
```js
$('<li class="plum">Plum</li>').insertBefore('.apple')
$.html()
//=> <ul id="fruits">
// <li class="plum">Plum</li>
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
```
#### .remove( [selector] )
Removes the set of matched elements from the DOM and all their children. `selector` filters the set of matched elements to be removed.
```js
$('.pear').remove()
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// </ul>
```
#### .replaceWith( content )
Replaces matched elements with `content`.
```js
var plum = $('<li class="plum">Plum</li>')
$('.pear').replaceWith(plum)
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="plum">Plum</li>
// </ul>
```
#### .empty()
Empties an element, removing all its children.
```js
$('ul').empty()
$.html()
//=> <ul id="fruits"></ul>
```
#### .html( [htmlString] )
Gets an html content string from the first selected element. If `htmlString` is specified, each selected element's content is replaced by the new content.
```js
$('.orange').html()
//=> Orange
$('#fruits').html('<li class="mango">Mango</li>').html()
//=> <li class="mango">Mango</li>
```
#### .text( [textString] )
Get the combined text contents of each element in the set of matched elements, including their descendants.. If `textString` is specified, each selected element's content is replaced by the new text content.
```js
$('.orange').text()
//=> Orange
$('ul').text()
//=> Apple
// Orange
// Pear
```
#### .css( [propertName] ) <br /> .css( [ propertyNames] ) <br /> .css( [propertyName], [value] ) <br /> .css( [propertName], [function] ) <br /> .css( [properties] )
Get the value of a style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.
### Rendering
When you're ready to render the document, you can use the `html` utility function:
```js
$.html()
//=> <ul id="fruits">
// <li class="apple">Apple</li>
// <li class="orange">Orange</li>
// <li class="pear">Pear</li>
// </ul>
```
If you want to return the outerHTML you can use `$.html(selector)`:
```js
$.html('.pear')
//=> <li class="pear">Pear</li>
```
By default, `html` will leave some tags open. Sometimes you may instead want to render a valid XML document. For example, you might parse the following XML snippet:
```xml
$ = cheerio.load('<media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>');
```
... and later want to render to XML. To do this, you can use the 'xml' utility function:
```js
$.xml()
//=> <media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>
```
### Miscellaneous
DOM element methods that don't fit anywhere else
#### .clone() ####
Clone the cheerio object.
```js
var moreFruit = $('#fruits').clone()
```
### Utilities
#### $.root
Sometimes you need to work with the top-level root element. To query it, you can use `$.root()`.
```js
$.root().append('<ul id="vegetables"></ul>').html();
//=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
```
#### $.contains( container, contained )
Checks to see if the `contained` DOM element is a descendent of the `container` DOM element.
#### $.parseHTML( data [, context ] [, keepScripts ] )
Parses a string into an array of DOM nodes. The `context` argument has no meaning for Cheerio, but it is maintained for API compatability.
### Plugins
Once you have loaded a document, you may extend the prototype or the equivalent `fn` property with custom plugin methods:
```js
var $ = cheerio.load('<html><body>Hello, <b>world</b>!</body></html>');
$.prototype.logHtml = function() {
console.log(this.html());
};
$('body').logHtml(); // logs "Hello, <b>world</b>!" to the console
```
### The "DOM Node" object
Cheerio collections are made up of objects that bear some resemblence to [browser-based DOM nodes](https://developer.mozilla.org/en-US/docs/Web/API/Node). You can expect them to define the following properties:
- `tagName`
- `parentNode`
- `previousSibling`
- `nextSibling`
- `nodeValue`
- `firstChild`
- `childNodes`
- `lastChild`
## Screencasts
http://vimeo.com/31950192
> This video tutorial is a follow-up to Nettut's "How to Scrape Web Pages with Node.js and jQuery", using cheerio instead of JSDOM + jQuery. This video shows how easy it is to use cheerio and how much faster cheerio is than JSDOM + jQuery.
## Test Coverage
Cheerio has high-test coverage, you can view the report [here](https://s3.amazonaws.com/MattMueller/Coverage/cheerio.html).
## Testing
To run the test suite, download the repository, then within the cheerio directory, run:
```shell
make setup
make test
```
This will download the development packages and run the test suite.
## Contributors
These are some of the contributors that have made cheerio possible:
```
project : cheerio
repo age : 2 years, 6 months
active : 285 days
commits : 762
files : 36
authors :
293 Matt Mueller 38.5%
133 Matthew Mueller 17.5%
92 Mike Pennisi 12.1%
54 David Chambers 7.1%
30 kpdecker 3.9%
19 Felix Böhm 2.5%
17 fb55 2.2%
15 Siddharth Mahendraker 2.0%
11 Adam Bretz 1.4%
8 Nazar Leush 1.0%
7 ironchefpython 0.9%
6 Jarno Leppänen 0.8%
5 Ben Sheldon 0.7%
5 Jos Shepherd 0.7%
5 Ryan Schmukler 0.7%
5 Steven Vachon 0.7%
4 Maciej Adwent 0.5%
4 Amir Abu Shareb 0.5%
3 jeremy.dentel@brandingbrand.com 0.4%
3 Andi Neck 0.4%
2 steve 0.3%
2 alexbardas 0.3%
2 finspin 0.3%
2 Ali Farhadi 0.3%
2 Chris Khoo 0.3%
2 Rob Ashton 0.3%
2 Thomas Heymann 0.3%
2 Jaro Spisak 0.3%
2 Dan Dascalescu 0.3%
2 Torstein Thune 0.3%
2 Wayne Larsen 0.3%
1 Timm Preetz 0.1%
1 Xavi 0.1%
1 Alex Shaindlin 0.1%
1 mattym 0.1%
1 Felix Böhm 0.1%
1 Farid Neshat 0.1%
1 Dmitry Mazuro 0.1%
1 Jeremy Hubble 0.1%
1 nevermind 0.1%
1 Manuel Alabor 0.1%
1 Matt Liegey 0.1%
1 Chris O'Hara 0.1%
1 Michael Holroyd 0.1%
1 Michiel De Mey 0.1%
1 Ben Atkin 0.1%
1 Rich Trott 0.1%
1 Rob "Hurricane" Ashton 0.1%
1 Robin Gloster 0.1%
1 Simon Boudrias 0.1%
1 Sindre Sorhus 0.1%
1 xiaohwan 0.1%
```
## Cheerio in the real world
Are you using cheerio in production? Add it to the [wiki](https://github.com/cheeriojs/cheerio/wiki/Cheerio-in-Production)!
## Special Thanks
This library stands on the shoulders of some incredible developers. A special thanks to:
__&#8226; @FB55 for node-htmlparser2 & CSSSelect:__
Felix has a knack for writing speedy parsing engines. He completely re-wrote both @tautologistic's `node-htmlparser` and @harry's `node-soupselect` from the ground up, making both of them much faster and more flexible. Cheerio would not be possible without his foundational work
__&#8226; @jQuery team for jQuery:__
The core API is the best of its class and despite dealing with all the browser inconsistencies the code base is extremely clean and easy to follow. Much of cheerio's implementation and documentation is from jQuery. Thanks guys.
__&#8226; @visionmedia:__
The style, the structure, the open-source"-ness" of this library comes from studying TJ's style and using many of his libraries. This dude consistently pumps out high-quality libraries and has always been more than willing to help or answer questions. You rock TJ.
## License
(The MIT License)
Copyright (c) 2012 Matt Mueller &lt;mattmuelle@gmail.com&gt;
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.

11
node_modules/cheerio/index.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Export cheerio (with )
*/
exports = module.exports = require('./lib/cheerio');
/*
Export the version
*/
exports.version = require('./package').version;

407
node_modules/cheerio/lib/api/attributes.js generated vendored Normal file
View File

@ -0,0 +1,407 @@
var _ = require('lodash'),
utils = require('../utils'),
isTag = utils.isTag,
domEach = utils.domEach,
hasOwn = Object.prototype.hasOwnProperty,
camelCase = utils.camelCase,
cssCase = utils.cssCase,
rspace = /\s+/,
dataAttrPrefix = 'data-',
// Lookup table for coercing string data-* attributes to their corresponding
// JavaScript primitives
primitives = {
null: null,
true: true,
false: false
},
// Attributes that are booleans
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
// Matches strings that look like JSON objects or arrays
rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/;
var getAttr = function(elem, name) {
if (!elem || !isTag(elem)) return;
if (!elem.attribs) {
elem.attribs = {};
}
// Return the entire attribs object if no attribute specified
if (!name) {
return elem.attribs;
}
if (hasOwn.call(elem.attribs, name)) {
// Get the (decoded) attribute
return rboolean.test(name) ? name : elem.attribs[name];
}
};
var setAttr = function(el, name, value) {
if (value === null) {
removeAttribute(el, name);
} else {
el.attribs[name] = value+'';
}
};
exports.attr = function(name, value) {
// Set the value (with attr map support)
if (typeof name === 'object' || value !== undefined) {
if (typeof value === 'function') {
return domEach(this, function(i, el) {
setAttr(el, name, value.call(el, i, el.attribs[name]));
});
}
return domEach(this, function(i, el) {
if (!isTag(el)) return;
if (typeof name === 'object') {
_.each(name, function(name, key) {
el.attribs[key] = name+'';
});
} else {
setAttr(el, name, value);
}
});
}
return getAttr(this[0], name);
};
var setData = function(el, name, value) {
if (typeof name === 'object') return _.extend(el.data, name);
if (typeof name === 'string' && value !== undefined) {
el.data[name] = value;
} else if (typeof name === 'object') {
_.exend(el.data, name);
}
};
// Read the specified attribute from the equivalent HTML5 `data-*` attribute,
// and (if present) cache the value in the node's internal data store. If no
// attribute name is specified, read *all* HTML5 `data-*` attributes in this
// manner.
var readData = function(el, name) {
var readAll = arguments.length === 1;
var domNames, domName, jsNames, jsName, value, idx, length;
if (readAll) {
domNames = Object.keys(el.attribs).filter(function(attrName) {
return attrName.slice(0, dataAttrPrefix.length) === dataAttrPrefix;
});
jsNames = domNames.map(function(domName) {
return camelCase(domName.slice(dataAttrPrefix.length));
});
} else {
domNames = [dataAttrPrefix + cssCase(name)];
jsNames = [name];
}
for (idx = 0, length = domNames.length; idx < length; ++idx) {
domName = domNames[idx];
jsName = jsNames[idx];
if (hasOwn.call(el.attribs, domName)) {
value = el.attribs[domName];
if (hasOwn.call(primitives, value)) {
value = primitives[value];
} else if (value === String(Number(value))) {
value = Number(value);
} else if (rbrace.test(value)) {
try {
value = JSON.parse(value);
} catch(e){ }
}
el.data[jsName] = value;
}
}
return readAll ? el.data : value;
};
exports.data = function(name, value) {
var elem = this[0];
if (!elem || !isTag(elem)) return;
if (!elem.data) {
elem.data = {};
}
// Return the entire data object if no data specified
if (!name) {
return readData(elem);
}
// Set the value (with attr map support)
if (typeof name === 'object' || value !== undefined) {
domEach(this, function(i, el) {
setData(el, name, value);
});
return this;
} else if (hasOwn.call(elem.data, name)) {
return elem.data[name];
}
return readData(elem, name);
};
/**
* Get the value of an element
*/
exports.val = function(value) {
var querying = arguments.length === 0,
element = this[0];
if(!element) return;
switch (element.name) {
case 'textarea':
return this.text(value);
case 'input':
switch (this.attr('type')) {
case 'radio':
if (querying) {
return this.attr('value');
} else {
this.attr('value', value);
return this;
}
break;
default:
return this.attr('value', value);
}
return;
case 'select':
var option = this.find('option:selected'),
returnValue;
if (option === undefined) return undefined;
if (!querying) {
if (!this.attr().hasOwnProperty('multiple') && typeof value == 'object') {
return this;
}
if (typeof value != 'object') {
value = [value];
}
this.find('option').removeAttr('selected');
for (var i = 0; i < value.length; i++) {
this.find('option[value="' + value[i] + '"]').attr('selected', '');
}
return this;
}
returnValue = option.attr('value');
if (this.attr().hasOwnProperty('multiple')) {
returnValue = [];
domEach(option, function(i, el) {
returnValue.push(el.attribs.value);
});
}
return returnValue;
case 'option':
if (!querying) {
this.attr('value', value);
return this;
}
return this.attr('value');
}
};
/**
* Remove an attribute
*/
var removeAttribute = function(elem, name) {
if (!elem.attribs || !hasOwn.call(elem.attribs, name))
return;
delete elem.attribs[name];
};
exports.removeAttr = function(name) {
domEach(this, function(i, elem) {
removeAttribute(elem, name);
});
return this;
};
exports.hasClass = function(className) {
return _.any(this, function(elem) {
var attrs = elem.attribs,
clazz = attrs && attrs['class'],
idx = -1,
end;
if (clazz) {
while ((idx = clazz.indexOf(className, idx+1)) > -1) {
end = idx + className.length;
if ((idx === 0 || rspace.test(clazz[idx-1]))
&& (end === clazz.length || rspace.test(clazz[end]))) {
return true;
}
}
}
});
};
exports.addClass = function(value) {
// Support functions
if (typeof value === 'function') {
return domEach(this, function(i, el) {
var className = el.attribs['class'] || '';
exports.addClass.call([el], value.call(el, i, className));
});
}
// Return if no value or not a string or function
if (!value || typeof value !== 'string') return this;
var classNames = value.split(rspace),
numElements = this.length;
for (var i = 0; i < numElements; i++) {
// If selected element isn't a tag, move on
if (!isTag(this[i])) continue;
// If we don't already have classes
var className = getAttr(this[i], 'class'),
numClasses,
setClass;
if (!className) {
setAttr(this[i], 'class', classNames.join(' ').trim());
} else {
setClass = ' ' + className + ' ';
numClasses = classNames.length;
// Check if class already exists
for (var j = 0; j < numClasses; j++) {
var appendClass = classNames[j] + ' ';
if (setClass.indexOf(' ' + appendClass) < 0)
setClass += appendClass;
}
setAttr(this[i], 'class', setClass.trim());
}
}
return this;
};
var splitClass = function(className) {
return className ? className.trim().split(rspace) : [];
};
exports.removeClass = function(value) {
var classes,
numClasses,
removeAll;
// Handle if value is a function
if (typeof value === 'function') {
return domEach(this, function(i, el) {
exports.removeClass.call(
[el], value.call(el, i, el.attribs['class'] || '')
);
});
}
classes = splitClass(value);
numClasses = classes.length;
removeAll = arguments.length === 0;
return domEach(this, function(i, el) {
if (!isTag(el)) return;
if (removeAll) {
// Short circuit the remove all case as this is the nice one
el.attribs.class = '';
} else {
var elClasses = splitClass(el.attribs.class),
index,
changed;
for (var j = 0; j < numClasses; j++) {
index = elClasses.indexOf(classes[j]);
if (index >= 0) {
elClasses.splice(index, 1);
changed = true;
// We have to do another pass to ensure that there are not duplicate
// classes listed
j--;
}
}
if (changed) {
el.attribs.class = elClasses.join(' ');
}
}
});
};
exports.toggleClass = function(value, stateVal) {
// Support functions
if (typeof value === 'function') {
return domEach(this, function(i, el) {
exports.toggleClass.call(
[el],
value.call(el, i, el.attribs['class'] || '', stateVal),
stateVal
);
});
}
// Return if no value or not a string or function
if (!value || typeof value !== 'string') return this;
var classNames = value.split(rspace),
numClasses = classNames.length,
state = typeof stateVal === 'boolean' ? stateVal ? 1 : -1 : 0,
numElements = this.length,
elementClasses,
index;
for (var i = 0; i < numElements; i++) {
// If selected element isn't a tag, move on
if (!isTag(this[i])) continue;
elementClasses = splitClass(this[i].attribs.class);
// Check if class already exists
for (var j = 0; j < numClasses; j++) {
// Check if the class name is currently defined
index = elementClasses.indexOf(classNames[j]);
// Add if stateValue === true or we are toggling and there is no value
if (state >= 0 && index < 0) {
elementClasses.push(classNames[j]);
} else if (state <= 0 && index >= 0) {
// Otherwise remove but only if the item exists
elementClasses.splice(index, 1);
}
}
this[i].attribs.class = elementClasses.join(' ');
}
return this;
};
exports.is = function (selector) {
if (selector) {
return this.filter(selector).length > 0;
}
return false;
};

118
node_modules/cheerio/lib/api/css.js generated vendored Normal file
View File

@ -0,0 +1,118 @@
var _ = require('lodash'),
domEach = require('../utils').domEach;
var toString = Object.prototype.toString;
/**
* Set / Get css.
*
* @param {String|Object} prop
* @param {String} val
* @return {self}
* @api public
*/
exports.css = function(prop, val) {
if (arguments.length === 2 ||
// When `prop` is a "plain" object
(toString.call(prop) === '[object Object]')) {
return domEach(this, function(idx, el) {
setCss(el, prop, val, idx);
});
} else {
return getCss(this[0], prop);
}
};
/**
* Set styles of all elements.
*
* @param {String|Object} prop
* @param {String} val
* @param {Number} idx - optional index within the selection
* @return {self}
* @api private
*/
function setCss(el, prop, val, idx) {
if ('string' == typeof prop) {
var styles = getCss(el);
if (typeof val === 'function') {
val = val.call(el, idx, styles[prop]);
}
if (val === '') {
delete styles[prop];
} else if (val != null) {
styles[prop] = val;
}
el.attribs.style = stringify(styles);
} else if ('object' == typeof prop) {
Object.keys(prop).forEach(function(k){
setCss(el, k, prop[k]);
});
}
}
/**
* Get parsed styles of the first element.
*
* @param {String} prop
* @return {Object}
* @api private
*/
function getCss(el, prop) {
var styles = parse(el.attribs.style);
if (typeof prop === 'string') {
return styles[prop];
} else if (Array.isArray(prop)) {
return _.pick(styles, prop);
} else {
return styles;
}
}
/**
* Stringify `obj` to styles.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function stringify(obj) {
return Object.keys(obj || {})
.reduce(function(str, prop){
return str += ''
+ (str ? ' ' : '')
+ prop
+ ': '
+ obj[prop]
+ ';';
}, '');
}
/**
* Parse `styles`.
*
* @param {String} styles
* @return {Object}
* @api private
*/
function parse(styles) {
styles = (styles || '').trim();
if (!styles) return {};
return styles
.split(';')
.reduce(function(obj, str){
var n = str.indexOf(':');
// skip if there is no :, or if it is the first/last character
if (n < 1 || n === str.length-1) return obj;
obj[str.slice(0,n).trim()] = str.slice(n+1).trim();
return obj;
}, {});
}

54
node_modules/cheerio/lib/api/forms.js generated vendored Normal file
View File

@ -0,0 +1,54 @@
// https://github.com/jquery/jquery/blob/2.1.3/src/manipulation/var/rcheckableType.js
// https://github.com/jquery/jquery/blob/2.1.3/src/serialize.js
var _ = require('lodash'),
submittableSelector = 'input,select,textarea,keygen',
rCRLF = /\r?\n/g,
rcheckableType = /^(?:checkbox|radio)$/i,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i;
exports.serializeArray = function() {
// Resolve all form elements from either forms or collections of form elements
var Cheerio = this.constructor;
return this.map(function() {
var elem = this;
var $elem = Cheerio(elem);
if (elem.name === 'form') {
return $elem.find(submittableSelector).toArray();
} else {
return $elem.filter(submittableSelector).toArray();
}
}).filter(function() {
var $elem = Cheerio(this);
var type = $elem.attr('type');
// Verify elements have a name (`attr.name`) and are not disabled (`:disabled`)
return $elem.attr('name') && !$elem.is(':disabled') &&
// and cannot be clicked (`[type=submit]`) or are used in `x-www-form-urlencoded` (`[type=file]`)
!rsubmitterTypes.test(type) &&
// and are either checked/don't have a checkable state
($elem.attr('checked') || !rcheckableType.test(type));
// Convert each of the elements to its value(s)
}).map(function(i, elem) {
var $elem = Cheerio(elem);
var name = $elem.attr('name');
var val = $elem.val();
// If there is no value set (e.g. `undefined`, `null`), then return nothing
if (val == null) {
return null;
} else {
// If we have an array of values (e.g. `<select multiple>`), return an array of key/value pairs
if (Array.isArray(val)) {
return _.map(val, function(val) {
// We trim replace any line endings (e.g. `\r` or `\r\n` with `\r\n`) to guarantee consistency across platforms
// These can occur inside of `<textarea>'s`
return {name: name, value: val.replace( rCRLF, '\r\n' )};
});
// Otherwise (e.g. `<input type="text">`, return only one key/value pair
} else {
return {name: name, value: val.replace( rCRLF, '\r\n' )};
}
}
// Convert our result to an array
}).get();
};

366
node_modules/cheerio/lib/api/manipulation.js generated vendored Normal file
View File

@ -0,0 +1,366 @@
var _ = require('lodash'),
parse = require('../parse'),
$ = require('../static'),
updateDOM = parse.update,
evaluate = parse.evaluate,
utils = require('../utils'),
domEach = utils.domEach,
cloneDom = utils.cloneDom,
slice = Array.prototype.slice;
// Create an array of nodes, recursing into arrays and parsing strings if
// necessary
exports._makeDomArray = function makeDomArray(elem, clone) {
if (elem == null) {
return [];
} else if (elem.cheerio) {
return clone ? cloneDom(elem.get(), elem.options) : elem.get();
} else if (Array.isArray(elem)) {
return _.flatten(elem.map(function(el) {
return this._makeDomArray(el, clone);
}, this));
} else if (typeof elem === 'string') {
return evaluate(elem, this.options);
} else {
return clone ? cloneDom([elem]) : [elem];
}
};
var _insert = function(concatenator) {
return function() {
var elems = slice.call(arguments),
lastIdx = this.length - 1;
return domEach(this, function(i, el) {
var dom, domSrc;
if (typeof elems[0] === 'function') {
domSrc = elems[0].call(el, i, $.html(el.children));
} else {
domSrc = elems;
}
dom = this._makeDomArray(domSrc, i < lastIdx);
concatenator(dom, el.children, el);
});
};
};
/*
* Modify an array in-place, removing some number of elements and adding new
* elements directly following them.
*
* @param {Array} array Target array to splice.
* @param {Number} spliceIdx Index at which to begin changing the array.
* @param {Number} spliceCount Number of elements to remove from the array.
* @param {Array} newElems Elements to insert into the array.
*
* @api private
*/
var uniqueSplice = function(array, spliceIdx, spliceCount, newElems, parent) {
var spliceArgs = [spliceIdx, spliceCount].concat(newElems),
prev = array[spliceIdx - 1] || null,
next = array[spliceIdx] || null;
var idx, len, prevIdx, node, oldParent;
// Before splicing in new elements, ensure they do not already appear in the
// current array.
for (idx = 0, len = newElems.length; idx < len; ++idx) {
node = newElems[idx];
oldParent = node.parent || node.root;
prevIdx = oldParent && oldParent.children.indexOf(newElems[idx]);
if (oldParent && prevIdx > -1) {
oldParent.children.splice(prevIdx, 1);
if (parent === oldParent && spliceIdx > prevIdx) {
spliceArgs[0]--;
}
}
node.root = null;
node.parent = parent;
if (node.prev) {
node.prev.next = node.next || null;
}
if (node.next) {
node.next.prev = node.prev || null;
}
node.prev = newElems[idx - 1] || prev;
node.next = newElems[idx + 1] || next;
}
if (prev) {
prev.next = newElems[0];
}
if (next) {
next.prev = newElems[newElems.length - 1];
}
return array.splice.apply(array, spliceArgs);
};
exports.append = _insert(function(dom, children, parent) {
uniqueSplice(children, children.length, 0, dom, parent);
});
exports.prepend = _insert(function(dom, children, parent) {
uniqueSplice(children, 0, 0, dom, parent);
});
exports.after = function() {
var elems = slice.call(arguments),
lastIdx = this.length - 1;
domEach(this, function(i, el) {
var parent = el.parent || el.root;
if (!parent) {
return;
}
var siblings = parent.children,
index = siblings.indexOf(el),
domSrc, dom;
// If not found, move on
if (index < 0) return;
if (typeof elems[0] === 'function') {
domSrc = elems[0].call(el, i, $.html(el.children));
} else {
domSrc = elems;
}
dom = this._makeDomArray(domSrc, i < lastIdx);
// Add element after `this` element
uniqueSplice(siblings, index + 1, 0, dom, parent);
});
return this;
};
exports.insertAfter = function(target) {
var clones = [],
self = this;
if (typeof target === 'string') {
target = this.constructor.call(this.constructor, target, null, this._originalRoot);
}
target = this._makeDomArray(target);
self.remove();
domEach(target, function(i, el) {
var clonedSelf = self._makeDomArray(self.clone());
var parent = el.parent || el.root;
if (!parent) {
return;
}
var siblings = parent.children,
index = siblings.indexOf(el);
// If not found, move on
if (index < 0) return;
// Add cloned `this` element(s) after target element
uniqueSplice(siblings, index + 1, 0, clonedSelf, parent);
clones.push(clonedSelf);
});
return this.constructor.call(this.constructor, this._makeDomArray(clones));
};
exports.before = function() {
var elems = slice.call(arguments),
lastIdx = this.length - 1;
domEach(this, function(i, el) {
var parent = el.parent || el.root;
if (!parent) {
return;
}
var siblings = parent.children,
index = siblings.indexOf(el),
domSrc, dom;
// If not found, move on
if (index < 0) return;
if (typeof elems[0] === 'function') {
domSrc = elems[0].call(el, i, $.html(el.children));
} else {
domSrc = elems;
}
dom = this._makeDomArray(domSrc, i < lastIdx);
// Add element before `el` element
uniqueSplice(siblings, index, 0, dom, parent);
});
return this;
};
exports.insertBefore = function(target) {
var clones = [],
self = this;
if (typeof target === 'string') {
target = this.constructor.call(this.constructor, target, null, this._originalRoot);
}
target = this._makeDomArray(target);
self.remove();
domEach(target, function(i, el) {
var clonedSelf = self._makeDomArray(self.clone());
var parent = el.parent || el.root;
if (!parent) {
return;
}
var siblings = parent.children,
index = siblings.indexOf(el);
// If not found, move on
if (index < 0) return;
// Add cloned `this` element(s) after target element
uniqueSplice(siblings, index, 0, clonedSelf, parent);
clones.push(clonedSelf);
});
return this.constructor.call(this.constructor, this._makeDomArray(clones));
};
/*
remove([selector])
*/
exports.remove = function(selector) {
var elems = this;
// Filter if we have selector
if (selector)
elems = elems.filter(selector);
domEach(elems, function(i, el) {
var parent = el.parent || el.root;
if (!parent) {
return;
}
var siblings = parent.children,
index = siblings.indexOf(el);
if (index < 0) return;
siblings.splice(index, 1);
if (el.prev) {
el.prev.next = el.next;
}
if (el.next) {
el.next.prev = el.prev;
}
el.prev = el.next = el.parent = el.root = null;
});
return this;
};
exports.replaceWith = function(content) {
var self = this;
domEach(this, function(i, el) {
var parent = el.parent || el.root;
if (!parent) {
return;
}
var siblings = parent.children,
dom = self._makeDomArray(typeof content === 'function' ? content.call(el, i, el) : content),
index;
// In the case that `dom` contains nodes that already exist in other
// structures, ensure those nodes are properly removed.
updateDOM(dom, null);
index = siblings.indexOf(el);
// Completely remove old element
uniqueSplice(siblings, index, 1, dom, parent);
el.parent = el.prev = el.next = el.root = null;
});
return this;
};
exports.empty = function() {
domEach(this, function(i, el) {
_.each(el.children, function(el) {
el.next = el.prev = el.parent = null;
});
el.children.length = 0;
});
return this;
};
/**
* Set/Get the HTML
*/
exports.html = function(str) {
if (str === undefined) {
if (!this[0] || !this[0].children) return null;
return $.html(this[0].children, this.options);
}
var opts = this.options;
domEach(this, function(i, el) {
_.each(el.children, function(el) {
el.next = el.prev = el.parent = null;
});
var content = str.cheerio ? str.clone().get() : evaluate(str, opts);
updateDOM(content, el);
});
return this;
};
exports.toString = function() {
return $.html(this, this.options);
};
exports.text = function(str) {
// If `str` is undefined, act as a "getter"
if (str === undefined) {
return $.text(this);
} else if (typeof str === 'function') {
// Function support
return domEach(this, function(i, el) {
var $el = [el];
return exports.text.call($el, str.call(el, i, $.text($el)));
});
}
// Append text node to each selected elements
domEach(this, function(i, el) {
_.each(el.children, function(el) {
el.next = el.prev = el.parent = null;
});
var elem = {
data: str,
type: 'text',
parent: el,
prev: null,
next: null,
children: []
};
updateDOM(elem, el);
});
return this;
};
exports.clone = function() {
return this._make(cloneDom(this.get(), this.options));
};

422
node_modules/cheerio/lib/api/traversing.js generated vendored Normal file
View File

@ -0,0 +1,422 @@
var _ = require('lodash'),
select = require('css-select'),
utils = require('../utils'),
domEach = utils.domEach,
uniqueSort = require('htmlparser2').DomUtils.uniqueSort,
isTag = utils.isTag;
exports.find = function(selectorOrHaystack) {
var elems = _.reduce(this, function(memo, elem) {
return memo.concat(_.filter(elem.children, isTag));
}, []);
var contains = this.constructor.contains;
var haystack;
if (selectorOrHaystack && typeof selectorOrHaystack !== 'string') {
if (selectorOrHaystack.cheerio) {
haystack = selectorOrHaystack.get();
} else {
haystack = [selectorOrHaystack];
}
return this._make(haystack.filter(function(elem) {
var idx, len;
for (idx = 0, len = this.length; idx < len; ++idx) {
if (contains(this[idx], elem)) {
return true;
}
}
}, this));
}
return this._make(select(selectorOrHaystack, elems, this.options));
};
// Get the parent of each element in the current set of matched elements,
// optionally filtered by a selector.
exports.parent = function(selector) {
var set = [];
domEach(this, function(idx, elem) {
var parentElem = elem.parent;
if (parentElem && set.indexOf(parentElem) < 0) {
set.push(parentElem);
}
});
if (arguments.length) {
set = exports.filter.call(set, selector, this);
}
return this._make(set);
};
exports.parents = function(selector) {
var parentNodes = [];
// When multiple DOM elements are in the original set, the resulting set will
// be in *reverse* order of the original elements as well, with duplicates
// removed.
this.get().reverse().forEach(function(elem) {
traverseParents(this, elem.parent, selector, Infinity)
.forEach(function(node) {
if (parentNodes.indexOf(node) === -1) {
parentNodes.push(node);
}
}
);
}, this);
return this._make(parentNodes);
};
exports.parentsUntil = function(selector, filter) {
var parentNodes = [], untilNode, untilNodes;
if (typeof selector === 'string') {
untilNode = select(selector, this.parents().toArray(), this.options)[0];
} else if (selector && selector.cheerio) {
untilNodes = selector.toArray();
} else if (selector) {
untilNode = selector;
}
// When multiple DOM elements are in the original set, the resulting set will
// be in *reverse* order of the original elements as well, with duplicates
// removed.
this.toArray().reverse().forEach(function(elem) {
while ((elem = elem.parent)) {
if ((untilNode && elem !== untilNode) ||
(untilNodes && untilNodes.indexOf(elem) === -1) ||
(!untilNode && !untilNodes)) {
if (isTag(elem) && parentNodes.indexOf(elem) === -1) { parentNodes.push(elem); }
} else {
break;
}
}
}, this);
return this._make(filter ? select(filter, parentNodes, this.options) : parentNodes);
};
// For each element in the set, get the first element that matches the selector
// by testing the element itself and traversing up through its ancestors in the
// DOM tree.
exports.closest = function(selector) {
var set = [];
if (!selector) {
return this._make(set);
}
domEach(this, function(idx, elem) {
var closestElem = traverseParents(this, elem, selector, 1)[0];
// Do not add duplicate elements to the set
if (closestElem && set.indexOf(closestElem) < 0) {
set.push(closestElem);
}
}.bind(this));
return this._make(set);
};
exports.next = function(selector) {
if (!this[0]) { return this; }
var elems = [];
_.forEach(this, function(elem) {
while ((elem = elem.next)) {
if (isTag(elem)) {
elems.push(elem);
return;
}
}
});
return selector ?
exports.filter.call(elems, selector, this) :
this._make(elems);
};
exports.nextAll = function(selector) {
if (!this[0]) { return this; }
var elems = [];
_.forEach(this, function(elem) {
while ((elem = elem.next)) {
if (isTag(elem) && elems.indexOf(elem) === -1) {
elems.push(elem);
}
}
});
return selector ?
exports.filter.call(elems, selector, this) :
this._make(elems);
};
exports.nextUntil = function(selector, filterSelector) {
if (!this[0]) { return this; }
var elems = [], untilNode, untilNodes;
if (typeof selector === 'string') {
untilNode = select(selector, this.nextAll().get(), this.options)[0];
} else if (selector && selector.cheerio) {
untilNodes = selector.get();
} else if (selector) {
untilNode = selector;
}
_.forEach(this, function(elem) {
while ((elem = elem.next)) {
if ((untilNode && elem !== untilNode) ||
(untilNodes && untilNodes.indexOf(elem) === -1) ||
(!untilNode && !untilNodes)) {
if (isTag(elem) && elems.indexOf(elem) === -1) {
elems.push(elem);
}
} else {
break;
}
}
});
return filterSelector ?
exports.filter.call(elems, filterSelector, this) :
this._make(elems);
};
exports.prev = function(selector) {
if (!this[0]) { return this; }
var elems = [];
_.forEach(this, function(elem) {
while ((elem = elem.prev)) {
if (isTag(elem)) {
elems.push(elem);
return;
}
}
});
return selector ?
exports.filter.call(elems, selector, this) :
this._make(elems);
};
exports.prevAll = function(selector) {
if (!this[0]) { return this; }
var elems = [];
_.forEach(this, function(elem) {
while ((elem = elem.prev)) {
if (isTag(elem) && elems.indexOf(elem) === -1) {
elems.push(elem);
}
}
});
return selector ?
exports.filter.call(elems, selector, this) :
this._make(elems);
};
exports.prevUntil = function(selector, filterSelector) {
if (!this[0]) { return this; }
var elems = [], untilNode, untilNodes;
if (typeof selector === 'string') {
untilNode = select(selector, this.prevAll().get(), this.options)[0];
} else if (selector && selector.cheerio) {
untilNodes = selector.get();
} else if (selector) {
untilNode = selector;
}
_.forEach(this, function(elem) {
while ((elem = elem.prev)) {
if ((untilNode && elem !== untilNode) ||
(untilNodes && untilNodes.indexOf(elem) === -1) ||
(!untilNode && !untilNodes)) {
if (isTag(elem) && elems.indexOf(elem) === -1) {
elems.push(elem);
}
} else {
break;
}
}
});
return filterSelector ?
exports.filter.call(elems, filterSelector, this) :
this._make(elems);
};
exports.siblings = function(selector) {
var parent = this.parent();
var elems = _.filter(
parent ? parent.children() : this.siblingsAndMe(),
function(elem) { return isTag(elem) && !this.is(elem); },
this
);
if (selector !== undefined) {
return exports.filter.call(elems, selector, this);
} else {
return this._make(elems);
}
};
exports.children = function(selector) {
var elems = _.reduce(this, function(memo, elem) {
return memo.concat(_.filter(elem.children, isTag));
}, []);
if (selector === undefined) return this._make(elems);
return exports.filter.call(elems, selector, this);
};
exports.contents = function() {
return this._make(_.reduce(this, function(all, elem) {
all.push.apply(all, elem.children);
return all;
}, []));
};
exports.each = function(fn) {
var i = 0, len = this.length;
while (i < len && fn.call(this[i], i, this[i]) !== false) ++i;
return this;
};
exports.map = function(fn) {
return this._make(_.reduce(this, function(memo, el, i) {
var val = fn.call(el, i, el);
return val == null ? memo : memo.concat(val);
}, []));
};
var makeFilterMethod = function(filterFn) {
return function(match, container) {
var testFn;
container = container || this;
if (typeof match === 'string') {
testFn = select.compile(match, container.options);
} else if (typeof match === 'function') {
testFn = function(el, i) {
return match.call(el, i, el);
};
} else if (match.cheerio) {
testFn = match.is.bind(match);
} else {
testFn = function(el) {
return match === el;
};
}
return container._make(filterFn(this, testFn));
};
};
exports.filter = makeFilterMethod(_.filter);
exports.not = makeFilterMethod(_.reject);
exports.has = function(selectorOrHaystack) {
var that = this;
return exports.filter.call(this, function() {
return that._make(this).find(selectorOrHaystack).length > 0;
});
};
exports.first = function() {
return this.length > 1 ? this._make(this[0]) : this;
};
exports.last = function() {
return this.length > 1 ? this._make(this[this.length - 1]) : this;
};
// Reduce the set of matched elements to the one at the specified index.
exports.eq = function(i) {
i = +i;
// Use the first identity optimization if possible
if (i === 0 && this.length <= 1) return this;
if (i < 0) i = this.length + i;
return this[i] ? this._make(this[i]) : this._make([]);
};
// Retrieve the DOM elements matched by the jQuery object.
exports.get = function(i) {
if (i == null) {
return Array.prototype.slice.call(this);
} else {
return this[i < 0 ? (this.length + i) : i];
}
};
// Search for a given element from among the matched elements.
exports.index = function(selectorOrNeedle) {
var $haystack, needle;
if (arguments.length === 0) {
$haystack = this.parent().children();
needle = this[0];
} else if (typeof selectorOrNeedle === 'string') {
$haystack = this._make(selectorOrNeedle);
needle = this[0];
} else {
$haystack = this;
needle = selectorOrNeedle.cheerio ? selectorOrNeedle[0] : selectorOrNeedle;
}
return $haystack.get().indexOf(needle);
};
exports.slice = function() {
return this._make([].slice.apply(this, arguments));
};
function traverseParents(self, elem, selector, limit) {
var elems = [];
while (elem && elems.length < limit) {
if (!selector || exports.filter.call([elem], selector, self).length) {
elems.push(elem);
}
elem = elem.parent;
}
return elems;
}
// End the most recent filtering operation in the current chain and return the
// set of matched elements to its previous state.
exports.end = function() {
return this.prevObject || this._make([]);
};
exports.add = function(other, context) {
var selection = this._make(other, context);
var contents = uniqueSort(selection.get().concat(this.get()));
for (var i = 0; i < contents.length; ++i) {
selection[i] = contents[i];
}
selection.length = contents.length;
return selection;
};
// Add the previous set of elements on the stack to the current set, optionally
// filtered by a selector.
exports.addBack = function(selector) {
return this.add(
arguments.length ? this.prevObject.filter(selector) : this.prevObject
);
};

162
node_modules/cheerio/lib/cheerio.js generated vendored Normal file
View File

@ -0,0 +1,162 @@
/*
Module dependencies
*/
var parse = require('./parse'),
_ = require('lodash');
/*
* The API
*/
var api = [
require('./api/attributes'),
require('./api/traversing'),
require('./api/manipulation'),
require('./api/css'),
require('./api/forms')
];
/*
* A simple way to check for HTML strings or ID strings
*/
var quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/;
/*
* Instance of cheerio
*/
var Cheerio = module.exports = function(selector, context, root, options) {
if (!(this instanceof Cheerio)) return new Cheerio(selector, context, root, options);
this.options = _.defaults(options || {}, this.options);
// $(), $(null), $(undefined), $(false)
if (!selector) return this;
if (root) {
if (typeof root === 'string') root = parse(root, this.options);
this._root = Cheerio.call(this, root);
}
// $($)
if (selector.cheerio) return selector;
// $(dom)
if (isNode(selector))
selector = [selector];
// $([dom])
if (Array.isArray(selector)) {
_.forEach(selector, function(elem, idx) {
this[idx] = elem;
}, this);
this.length = selector.length;
return this;
}
// $(<html>)
if (typeof selector === 'string' && isHtml(selector)) {
return Cheerio.call(this, parse(selector, this.options).children);
}
// If we don't have a context, maybe we have a root, from loading
if (!context) {
context = this._root;
} else if (typeof context === 'string') {
if (isHtml(context)) {
// $('li', '<ul>...</ul>')
context = parse(context, this.options);
context = Cheerio.call(this, context);
} else {
// $('li', 'ul')
selector = [context, selector].join(' ');
context = this._root;
}
// $('li', node), $('li', [nodes])
} else if (!context.cheerio) {
context = Cheerio.call(this, context);
}
// If we still don't have a context, return
if (!context) return this;
// #id, .class, tag
return context.find(selector);
};
/**
* Mix in `static`
*/
_.extend(Cheerio, require('./static'));
/*
* Set a signature of the object
*/
Cheerio.prototype.cheerio = '[cheerio object]';
/*
* Cheerio default options
*/
Cheerio.prototype.options = {
withDomLvl1: true,
normalizeWhitespace: false,
xmlMode: false,
decodeEntities: true
};
/*
* Make cheerio an array-like object
*/
Cheerio.prototype.length = 0;
Cheerio.prototype.splice = Array.prototype.splice;
/*
* Check if string is HTML
*/
var isHtml = function(str) {
// Faster than running regex, if str starts with `<` and ends with `>`, assume it's HTML
if (str.charAt(0) === '<' && str.charAt(str.length - 1) === '>' && str.length >= 3) return true;
// Run the regex
var match = quickExpr.exec(str);
return !!(match && match[1]);
};
/*
* Make a cheerio object
*
* @api private
*/
Cheerio.prototype._make = function(dom, context) {
var cheerio = new this.constructor(dom, context, this._root, this.options);
cheerio.prevObject = this;
return cheerio;
};
/**
* Turn a cheerio object into an array
*
* @deprecated
*/
Cheerio.prototype.toArray = function() {
return this.get();
};
/**
* Plug in the API
*/
api.forEach(function(mod) {
_.extend(Cheerio.prototype, mod);
});
var isNode = function(obj) {
return obj.name || obj.type === 'text' || obj.type === 'comment';
};

86
node_modules/cheerio/lib/parse.js generated vendored Normal file
View File

@ -0,0 +1,86 @@
/*
Module Dependencies
*/
var htmlparser = require('htmlparser2');
/*
Parser
*/
exports = module.exports = function(content, options) {
var dom = exports.evaluate(content, options),
// Generic root element
root = exports.evaluate('<root></root>', options)[0];
root.type = 'root';
// Update the dom using the root
exports.update(dom, root);
return root;
};
exports.evaluate = function(content, options) {
// options = options || $.fn.options;
var dom;
if (typeof content === 'string' || Buffer.isBuffer(content)) {
dom = htmlparser.parseDOM(content, options);
} else {
dom = content;
}
return dom;
};
/*
Update the dom structure, for one changed layer
*/
exports.update = function(arr, parent) {
// normalize
if (!Array.isArray(arr)) arr = [arr];
// Update parent
if (parent) {
parent.children = arr;
} else {
parent = null;
}
// Update neighbors
for (var i = 0; i < arr.length; i++) {
var node = arr[i];
// Cleanly remove existing nodes from their previous structures.
var oldParent = node.parent || node.root,
oldSiblings = oldParent && oldParent.children;
if (oldSiblings && oldSiblings !== arr) {
oldSiblings.splice(oldSiblings.indexOf(node), 1);
if (node.prev) {
node.prev.next = node.next;
}
if (node.next) {
node.next.prev = node.prev;
}
}
if (parent) {
node.prev = arr[i - 1] || null;
node.next = arr[i + 1] || null;
} else {
node.prev = node.next = null;
}
if (parent && parent.type === 'root') {
node.root = parent;
node.parent = null;
} else {
node.root = null;
node.parent = parent;
}
}
return parent;
};
// module.exports = $.extend(exports);

182
node_modules/cheerio/lib/static.js generated vendored Normal file
View File

@ -0,0 +1,182 @@
/**
* Module dependencies
*/
var select = require('css-select'),
parse = require('./parse'),
serialize = require('dom-serializer'),
_ = require('lodash');
/**
* $.load(str)
*/
exports.load = function(content, options) {
var Cheerio = require('./cheerio');
options = _.defaults(options || {}, Cheerio.prototype.options);
var root = parse(content, options);
var initialize = function(selector, context, r, opts) {
if (!(this instanceof initialize)) {
return new initialize(selector, context, r, opts);
}
opts = _.defaults(opts || {}, options);
return Cheerio.call(this, selector, context, r || root, opts);
};
// Ensure that selections created by the "loaded" `initialize` function are
// true Cheerio instances.
initialize.prototype = Object.create(Cheerio.prototype);
initialize.prototype.constructor = initialize;
// Mimic jQuery's prototype alias for plugin authors.
initialize.fn = initialize.prototype;
// Keep a reference to the top-level scope so we can chain methods that implicitly
// resolve selectors; e.g. $("<span>").(".bar"), which otherwise loses ._root
initialize.prototype._originalRoot = root;
// Add in the static methods
_.merge(initialize, exports);
// Add in the root
initialize._root = root;
// store options
initialize._options = options;
return initialize;
};
/*
* Helper function
*/
function render(that, dom, options) {
if (!dom) {
if (that._root && that._root.children) {
dom = that._root.children;
} else {
return '';
}
} else if (typeof dom === 'string') {
dom = select(dom, that._root, options);
}
return serialize(dom, options);
}
/**
* $.html([selector | dom], [options])
*/
exports.html = function(dom, options) {
var Cheerio = require('./cheerio');
// be flexible about parameters, sometimes we call html(),
// with options as only parameter
// check dom argument for dom element specific properties
// assume there is no 'length' or 'type' properties in the options object
if (Object.prototype.toString.call(dom) === '[object Object]' && !options && !('length' in dom) && !('type' in dom))
{
options = dom;
dom = undefined;
}
// sometimes $.html() used without preloading html
// so fallback non existing options to the default ones
options = _.defaults(options || {}, this._options, Cheerio.prototype.options);
return render(this, dom, options);
};
/**
* $.xml([selector | dom])
*/
exports.xml = function(dom) {
var options = _.defaults({xmlMode: true}, this._options);
return render(this, dom, options);
};
/**
* $.text(dom)
*/
exports.text = function(elems) {
if (!elems) return '';
var ret = '',
len = elems.length,
elem;
for (var i = 0; i < len; i++) {
elem = elems[i];
if (elem.type === 'text') ret += elem.data;
else if (elem.children && elem.type !== 'comment') {
ret += exports.text(elem.children);
}
}
return ret;
};
/**
* $.parseHTML(data [, context ] [, keepScripts ])
* Parses a string into an array of DOM nodes. The `context` argument has no
* meaning for Cheerio, but it is maintained for API compatibility with jQuery.
*/
exports.parseHTML = function(data, context, keepScripts) {
var parsed;
if (!data || typeof data !== 'string') {
return null;
}
if (typeof context === 'boolean') {
keepScripts = context;
}
parsed = this.load(data);
if (!keepScripts) {
parsed('script').remove();
}
// The `children` array is used by Cheerio internally to group elements that
// share the same parents. When nodes created through `parseHTML` are
// inserted into previously-existing DOM structures, they will be removed
// from the `children` array. The results of `parseHTML` should remain
// constant across these operations, so a shallow copy should be returned.
return parsed.root()[0].children.slice();
};
/**
* $.root()
*/
exports.root = function() {
return this(this._root);
};
/**
* $.contains()
*/
exports.contains = function(container, contained) {
// According to the jQuery API, an element does not "contain" itself
if (contained === container) {
return false;
}
// Step up the descendants, stopping when the root element is reached
// (signaled by `.parent` returning a reference to the same object)
while (contained && contained !== contained.parent) {
contained = contained.parent;
if (contained === container) {
return true;
}
}
return false;
};

65
node_modules/cheerio/lib/utils.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
var parse = require('./parse'),
render = require('dom-serializer');
/**
* HTML Tags
*/
var tags = { tag: true, script: true, style: true };
/**
* Check if the DOM element is a tag
*
* isTag(type) includes <script> and <style> tags
*/
exports.isTag = function(type) {
if (type.type) type = type.type;
return tags[type] || false;
};
/**
* Convert a string to camel case notation.
* @param {String} str String to be converted.
* @return {String} String in camel case notation.
*/
exports.camelCase = function(str) {
return str.replace(/[_.-](\w|$)/g, function(_, x) {
return x.toUpperCase();
});
};
/**
* Convert a string from camel case to "CSS case", where word boundaries are
* described by hyphens ("-") and all characters are lower-case.
* @param {String} str String to be converted.
* @return {string} String in "CSS case".
*/
exports.cssCase = function(str) {
return str.replace(/[A-Z]/g, '-$&').toLowerCase();
};
/**
* Iterate over each DOM element without creating intermediary Cheerio instances.
*
* This is indented for use internally to avoid otherwise unnecessary memory pressure introduced
* by _make.
*/
exports.domEach = function(cheerio, fn) {
var i = 0, len = cheerio.length;
while (i < len && fn.call(cheerio, i, cheerio[i]) !== false) ++i;
return cheerio;
};
/**
* Create a deep copy of the given DOM structure by first rendering it to a
* string and then parsing the resultant markup.
*
* @argument {Object} dom - The htmlparser2-compliant DOM structure
* @argument {Object} options - The parsing/rendering options
*/
exports.cloneDom = function(dom, options) {
return parse(render(dom, options), options).children;
};

111
node_modules/cheerio/package.json generated vendored Normal file
View File

@ -0,0 +1,111 @@
{
"_args": [
[
"cheerio@^0.19.0",
"/Users/okennedy/Documents/Website/node_modules/metalsmith-broken-link-checker"
]
],
"_from": "cheerio@>=0.19.0 <0.20.0",
"_id": "cheerio@0.19.0",
"_inCache": true,
"_installable": true,
"_location": "/cheerio",
"_nodeVersion": "1.5.1",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "2.7.1",
"_phantomChildren": {},
"_requested": {
"name": "cheerio",
"raw": "cheerio@^0.19.0",
"rawSpec": "^0.19.0",
"scope": null,
"spec": ">=0.19.0 <0.20.0",
"type": "range"
},
"_requiredBy": [
"/metalsmith-broken-link-checker"
],
"_resolved": "https://registry.npmjs.org/cheerio/-/cheerio-0.19.0.tgz",
"_shasum": "772e7015f2ee29965096d71ea4175b75ab354925",
"_shrinkwrap": null,
"_spec": "cheerio@^0.19.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/metalsmith-broken-link-checker",
"author": {
"email": "mattmuelle@gmail.com",
"name": "Matt Mueller",
"url": "mat.io"
},
"bugs": {
"url": "https://github.com/cheeriojs/cheerio/issues"
},
"dependencies": {
"css-select": "~1.0.0",
"dom-serializer": "~0.1.0",
"entities": "~1.1.1",
"htmlparser2": "~3.8.1",
"lodash": "^3.2.0"
},
"description": "Tiny, fast, and elegant implementation of core jQuery designed specifically for the server",
"devDependencies": {
"benchmark": "~1.0.0",
"coveralls": "~2.10",
"expect.js": "~0.3.1",
"istanbul": "~0.2",
"jsdom": "~0.8.9",
"jshint": "~2.5.1",
"mocha": "*",
"xyz": "~0.5.0"
},
"directories": {},
"dist": {
"shasum": "772e7015f2ee29965096d71ea4175b75ab354925",
"tarball": "http://registry.npmjs.org/cheerio/-/cheerio-0.19.0.tgz"
},
"engines": {
"node": ">= 0.6"
},
"gitHead": "9e3746d391c47a09ad5b130d770c747a0d673869",
"homepage": "https://github.com/cheeriojs/cheerio",
"keywords": [
"html",
"htmlparser",
"jquery",
"parser",
"scraper",
"selector"
],
"license": "MIT",
"main": "./index.js",
"maintainers": [
{
"name": "mattmueller",
"email": "mattmuelle@gmail.com"
},
{
"name": "davidchambers",
"email": "dc@davidchambers.me"
},
{
"name": "jugglinmike",
"email": "mike@mikepennisi.com"
},
{
"name": "feedic",
"email": "me@feedic.com"
}
],
"name": "cheerio",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/cheeriojs/cheerio.git"
},
"scripts": {
"test": "make test"
},
"version": "0.19.0"
}

17
node_modules/cheerio/scripts/prepublish generated vendored Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e
tmp="$(mktemp -t "$(basename "$0").XXXXXXXXXX")"
log="$(git --no-pager log --no-merges --pretty="format: * %s (%an)" $PREVIOUS_VERSION..)"
printf "
$VERSION / $(date +"%Y-%m-%d")
==================
$log
" >"$tmp"
cat History.md >>"$tmp"
mv "$tmp" History.md
git add History.md

9
node_modules/cheerio/test/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,9 @@
{
"extends": "../.jshintrc",
"globals": {
"expect": true,
"it": true,
"describe": true,
"beforeEach": true
}
}

677
node_modules/cheerio/test/api/attributes.js generated vendored Normal file
View File

@ -0,0 +1,677 @@
var expect = require('expect.js');
var cheerio = require('../..');
var fruits = require('../fixtures').fruits;
var vegetables = require('../fixtures').vegetables;
var food = require('../fixtures').food;
var chocolates = require('../fixtures').chocolates;
var inputs = require('../fixtures').inputs;
var toArray = Function.call.bind(Array.prototype.slice);
describe('$(...)', function() {
var $;
beforeEach(function() {
$ = cheerio.load(fruits);
});
describe('.attr', function() {
it('() : should get all the attributes', function() {
var attrs = $('ul').attr();
expect(attrs.id).to.equal('fruits');
});
it('(invalid key) : invalid attr should get undefined', function() {
var attr = $('.apple').attr('lol');
expect(attr).to.be(undefined);
});
it('(valid key) : valid attr should get value', function() {
var cls = $('.apple').attr('class');
expect(cls).to.equal('apple');
});
it('(valid key) : valid attr should get name when boolean', function() {
var attr = $('<input name=email autofocus>').attr('autofocus');
expect(attr).to.equal('autofocus');
});
it('(key, value) : should set attr', function() {
var $pear = $('.pear').attr('id', 'pear');
expect($('#pear')).to.have.length(1);
expect($pear).to.be.a($);
});
it('(key, value) : should set attr', function() {
var $el = cheerio('<div></div> <div></div>').attr('class', 'pear');
expect($el[0].attribs['class']).to.equal('pear');
expect($el[1].attribs).to.equal(undefined);
expect($el[2].attribs['class']).to.equal('pear');
});
it('(key, value) : should return an empty object for an empty object', function() {
var $src = $().attr('key', 'value');
expect($src.length).to.equal(0);
expect($src[0]).to.be(undefined);
});
it('(map) : object map should set multiple attributes', function() {
$('.apple').attr({
id: 'apple',
style: 'color:red;',
'data-url': 'http://apple.com'
});
var attrs = $('.apple').attr();
expect(attrs.id).to.equal('apple');
expect(attrs.style).to.equal('color:red;');
expect(attrs['data-url']).to.equal('http://apple.com');
});
it('(key, function) : should call the function and update the attribute with the return value', function() {
var $fruits = $('#fruits');
$fruits.attr('id', function(index, value) {
expect(index).to.equal(0);
expect(value).to.equal('fruits');
return 'ninja';
});
var attrs = $fruits.attr();
expect(attrs.id).to.equal('ninja');
});
it('(key, value) : should correctly encode then decode unsafe values', function() {
var $apple = $('.apple');
$apple.attr('href', 'http://github.com/"><script>alert("XSS!")</script><br');
expect($apple.attr('href')).to.equal('http://github.com/"><script>alert("XSS!")</script><br');
$apple.attr('href', 'http://github.com/"><script>alert("XSS!")</script><br');
expect($apple.html()).to.not.contain('<script>alert("XSS!")</script>');
});
it('(key, value) : should coerce values to a string', function() {
var $apple = $('.apple');
$apple.attr('data-test', 1);
expect($apple[0].attribs['data-test']).to.equal('1');
expect($apple.attr('data-test')).to.equal('1');
});
it('(key, value) : handle removed boolean attributes', function() {
var $apple = $('.apple');
$apple.attr('autofocus', 'autofocus');
expect($apple.attr('autofocus')).to.equal('autofocus');
$apple.removeAttr('autofocus');
expect($apple.attr('autofocus')).to.be(undefined);
});
it('(key, value) : should remove non-boolean attributes with names or values similar to boolean ones', function() {
var $apple = $('.apple');
$apple.attr('data-autofocus', 'autofocus');
expect($apple.attr('data-autofocus')).to.equal('autofocus');
$apple.removeAttr('data-autofocus');
expect($apple.attr('data-autofocus')).to.be(undefined);
});
});
describe('.data', function() {
beforeEach(function() {
$ = cheerio.load(chocolates);
});
it('() : should get all data attributes initially declared in the markup', function() {
var data = $('.linth').data();
expect(data).to.eql({
highlight: 'Lindor',
origin: 'swiss'
});
});
it('() : should get all data set via `data`', function() {
var $el = cheerio('<div>');
$el.data('a', 1);
$el.data('b', 2);
expect($el.data()).to.eql({
a: 1,
b: 2
});
});
it('() : should get all data attributes initially declared in the markup merged with all data additionally set via `data`', function() {
var $el = cheerio('<div data-a="a">');
$el.data('b', 'b');
expect($el.data()).to.eql({
a: 'a',
b: 'b'
});
});
it('() : no data attribute should return an empty object', function() {
var data = $('.cailler').data();
expect(data).to.be.empty();
});
it('(invalid key) : invalid data attribute should return `undefined` ', function() {
var data = $('.frey').data('lol');
expect(data).to.be(undefined);
});
it('(valid key) : valid data attribute should get value', function() {
var highlight = $('.linth').data('highlight');
var origin = $('.linth').data('origin');
expect(highlight).to.equal('Lindor');
expect(origin).to.equal('swiss');
});
it('(key) : should translate camel-cased key values to hyphen-separated versions', function() {
var $el = cheerio('<div data--three-word-attribute="a" data-foo-Bar_BAZ-="b">');
expect($el.data('ThreeWordAttribute')).to.be('a');
expect($el.data('fooBar_baz-')).to.be('b');
});
it('(key) : should retrieve object values', function() {
var data = {};
var $el = cheerio('<div>');
$el.data('test', data);
expect($el.data('test')).to.be(data);
});
it('(key) : should parse JSON data derived from the markup', function() {
var $el = cheerio('<div data-json="[1, 2, 3]">');
expect($el.data('json')).to.eql([1,2,3]);
});
it('(key) : should not parse JSON data set via the `data` API', function() {
var $el = cheerio('<div>');
$el.data('json', '[1, 2, 3]');
expect($el.data('json')).to.be('[1, 2, 3]');
});
// See http://api.jquery.com/data/ and http://bugs.jquery.com/ticket/14523
it('(key) : should ignore the markup value after the first access', function() {
var $el = cheerio('<div data-test="a">');
expect($el.data('test')).to.be('a');
$el.attr('data-test', 'b');
expect($el.data('test')).to.be('a');
});
it('(key) : should recover from malformed JSON', function() {
var $el = cheerio('<div data-custom="{{templatevar}}">');
expect($el.data('custom')).to.be('{{templatevar}}');
});
it('(hyphen key) : data addribute with hyphen should be camelized ;-)', function() {
var data = $('.frey').data();
expect(data).to.eql({
taste: 'sweet',
bestCollection: 'Mahony'
});
});
it('(key, value) : should set data attribute', function() {
// Adding as object.
var a = $('.frey').data({
balls: 'giandor'
});
// Adding as string.
var b = $('.linth').data('snack', 'chocoletti');
expect(a.data('balls')).to.eql('giandor');
expect(b.data('snack')).to.eql('chocoletti');
});
it('(map) : object map should set multiple data attributes', function() {
var data = $('.linth').data({
id: 'Cailler',
flop: 'Pippilotti Rist',
top: 'Frigor',
url: 'http://www.cailler.ch/'
})['0'].data;
expect(data.id).to.equal('Cailler');
expect(data.flop).to.equal('Pippilotti Rist');
expect(data.top).to.equal('Frigor');
expect(data.url).to.equal('http://www.cailler.ch/');
});
describe('(attr) : data-* attribute type coercion :', function() {
it('boolean', function() {
var $el = cheerio('<div data-bool="true">');
expect($el.data('bool')).to.be(true);
});
it('number', function() {
var $el = cheerio('<div data-number="23">');
expect($el.data('number')).to.be(23);
});
it('number (scientific notation is not coerced)', function() {
var $el = cheerio('<div data-sci="1E10">');
expect($el.data('sci')).to.be('1E10');
});
it('null', function() {
var $el = cheerio('<div data-null="null">');
expect($el.data('null')).to.be(null);
});
it('object', function() {
var $el = cheerio('<div data-obj=\'{ "a": 45 }\'>');
expect($el.data('obj')).to.eql({ a: 45 });
});
it('array', function() {
var $el = cheerio('<div data-array="[1, 2, 3]">');
expect($el.data('array')).to.eql([1, 2, 3]);
});
});
});
describe('.val', function() {
beforeEach(function() {
$ = cheerio.load(inputs);
});
it('.val(): on select should get value', function() {
var val = $('select#one').val();
expect(val).to.equal('option_selected');
});
it('.val(): on option should get value', function() {
var val = $('select#one option').eq(0).val();
expect(val).to.equal('option_not_selected');
});
it('.val(): on text input should get value', function() {
var val = $('input[type="text"]').val();
expect(val).to.equal('input_text');
});
it('.val(): on checked checkbox should get value', function() {
var val = $('input[name="checkbox_on"]').val();
expect(val).to.equal('on');
});
it('.val(): on unchecked checkbox should get value', function() {
var val = $('input[name="checkbox_off"]').val();
expect(val).to.equal('off');
});
it('.val(): on radio should get value', function() {
var val = $('input[type="radio"]').val();
expect(val).to.equal('off');
});
it('.val(): on multiple select should get an array of values', function() {
var val = $('select#multi').val();
expect(val).to.have.length(2);
});
it('.val(value): on input text should set value', function() {
var element = $('input[type="text"]').val('test');
expect(element.val()).to.equal('test');
});
it('.val(value): on select should set value', function() {
var element = $('select#one').val('option_not_selected');
expect(element.val()).to.equal('option_not_selected');
});
it('.val(value): on option should set value', function() {
var element = $('select#one option').eq(0).val('option_changed');
expect(element.val()).to.equal('option_changed');
});
it('.val(value): on radio should set value', function() {
var element = $('input[name="radio"]').val('off');
expect(element.val()).to.equal('off');
});
it('.val(value): on radio with special characters should set value', function() {
var element = $('input[name="radio[brackets]"]').val('off');
expect(element.val()).to.equal('off');
});
it('.val(values): on multiple select should set multiple values', function() {
var element = $('select#multi').val(['1', '3', '4']);
expect(element.val()).to.have.length(3);
});
});
describe('.removeAttr', function() {
it('(key) : should remove a single attr', function() {
var $fruits = $('#fruits');
expect($fruits.attr('id')).to.not.be(undefined);
$fruits.removeAttr('id');
expect($fruits.attr('id')).to.be(undefined);
});
it('should return cheerio object', function() {
var obj = $('ul').removeAttr('id');
expect(obj).to.be.a($);
});
});
describe('.hasClass', function() {
function test(attr) {
return cheerio('<div class="' + attr + '"></div>');
}
it('(valid class) : should return true', function() {
var cls = $('.apple').hasClass('apple');
expect(cls).to.be.ok();
expect(test('foo').hasClass('foo')).to.be.ok();
expect(test('foo bar').hasClass('foo')).to.be.ok();
expect(test('bar foo').hasClass('foo')).to.be.ok();
expect(test('bar foo bar').hasClass('foo')).to.be.ok();
});
it('(invalid class) : should return false', function() {
var cls = $('#fruits').hasClass('fruits');
expect(cls).to.not.be.ok();
expect(test('foo-bar').hasClass('foo')).to.not.be.ok();
expect(test('foo-bar').hasClass('foo')).to.not.be.ok();
expect(test('foo-bar').hasClass('foo-ba')).to.not.be.ok();
});
it('should check multiple classes', function() {
// Add a class
$('.apple').addClass('red');
expect($('.apple').hasClass('apple')).to.be.ok();
expect($('.apple').hasClass('red')).to.be.ok();
// Remove one and test again
$('.apple').removeClass('apple');
expect($('li').eq(0).hasClass('apple')).to.not.be.ok();
// expect($('li', $fruits).eq(0).hasClass('red')).to.be.ok();
});
});
describe('.addClass', function() {
it('(first class) : should add the class to the element', function() {
var $fruits = $('#fruits');
$fruits.addClass('fruits');
var cls = $fruits.hasClass('fruits');
expect(cls).to.be.ok();
});
it('(single class) : should add the class to the element', function() {
$('.apple').addClass('fruit');
var cls = $('.apple').hasClass('fruit');
expect(cls).to.be.ok();
});
it('(class): adds classes to many selected items', function() {
$('li').addClass('fruit');
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.orange').hasClass('fruit')).to.be.ok();
expect($('.pear').hasClass('fruit')).to.be.ok();
});
it('(class class class) : should add multiple classes to the element', function() {
$('.apple').addClass('fruit red tasty');
expect($('.apple').hasClass('apple')).to.be.ok();
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.apple').hasClass('red')).to.be.ok();
expect($('.apple').hasClass('tasty')).to.be.ok();
});
it('(fn) : should add classes returned from the function', function() {
var $fruits = $('#fruits').children();
var args = [];
var thisVals = [];
var toAdd = ['apple red', '', undefined];
$fruits.addClass(function(idx) {
args.push(toArray(arguments));
thisVals.push(this);
return toAdd[idx];
});
expect(args).to.eql([
[0, 'apple'],
[1, 'orange'],
[2, 'pear']
]);
expect(thisVals).to.eql([
$fruits[0],
$fruits[1],
$fruits[2]
]);
expect($fruits.eq(0).hasClass('apple')).to.be.ok();
expect($fruits.eq(0).hasClass('red')).to.be.ok();
expect($fruits.eq(1).hasClass('orange')).to.be.ok();
expect($fruits.eq(2).hasClass('pear')).to.be.ok();
});
});
describe('.removeClass', function() {
it('() : should remove all the classes', function() {
$('.pear').addClass('fruit');
$('.pear').removeClass();
expect($('.pear').attr('class')).to.be(undefined);
});
it('("") : should not modify class list', function() {
var $fruits = $('#fruits');
$fruits.children().removeClass('');
expect($('.apple')).to.have.length(1);
});
it('(invalid class) : should not remove anything', function() {
$('.pear').removeClass('fruit');
expect($('.pear').hasClass('pear')).to.be.ok();
});
it('(no class attribute) : should not throw an exception', function() {
var $vegetables = cheerio(vegetables);
expect(function() {
$('li', $vegetables).removeClass('vegetable');
})
.to.not.throwException();
});
it('(single class) : should remove a single class from the element', function() {
$('.pear').addClass('fruit');
expect($('.pear').hasClass('fruit')).to.be.ok();
$('.pear').removeClass('fruit');
expect($('.pear').hasClass('fruit')).to.not.be.ok();
expect($('.pear').hasClass('pear')).to.be.ok();
});
it('(single class) : should remove a single class from multiple classes on the element', function() {
$('.pear').addClass('fruit green tasty');
expect($('.pear').hasClass('fruit')).to.be.ok();
expect($('.pear').hasClass('green')).to.be.ok();
expect($('.pear').hasClass('tasty')).to.be.ok();
$('.pear').removeClass('green');
expect($('.pear').hasClass('fruit')).to.be.ok();
expect($('.pear').hasClass('green')).to.not.be.ok();
expect($('.pear').hasClass('tasty')).to.be.ok();
});
it('(class class class) : should remove multiple classes from the element', function() {
$('.apple').addClass('fruit red tasty');
expect($('.apple').hasClass('apple')).to.be.ok();
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.apple').hasClass('red')).to.be.ok();
expect($('.apple').hasClass('tasty')).to.be.ok();
$('.apple').removeClass('apple red tasty');
expect($('.fruit').hasClass('apple')).to.not.be.ok();
expect($('.fruit').hasClass('red')).to.not.be.ok();
expect($('.fruit').hasClass('tasty')).to.not.be.ok();
expect($('.fruit').hasClass('fruit')).to.be.ok();
});
it('(class) : should remove all occurrences of a class name', function() {
var $div = cheerio('<div class="x x y x z"></div>');
expect($div.removeClass('x').hasClass('x')).to.be(false);
});
it('(fn) : should remove classes returned from the function', function() {
var $fruits = $('#fruits').children();
var args = [];
var thisVals = [];
var toAdd = ['apple red', '', undefined];
$fruits.removeClass(function(idx) {
args.push(toArray(arguments));
thisVals.push(this);
return toAdd[idx];
});
expect(args).to.eql([
[0, 'apple'],
[1, 'orange'],
[2, 'pear']
]);
expect(thisVals).to.eql([
$fruits[0],
$fruits[1],
$fruits[2]
]);
expect($fruits.eq(0).hasClass('apple')).to.not.be.ok();
expect($fruits.eq(0).hasClass('red')).to.not.be.ok();
expect($fruits.eq(1).hasClass('orange')).to.be.ok();
expect($fruits.eq(2).hasClass('pear')).to.be.ok();
});
});
describe('.toggleClass', function() {
it('(class class) : should toggle multiple classes from the element', function() {
$('.apple').addClass('fruit');
expect($('.apple').hasClass('apple')).to.be.ok();
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.apple').hasClass('red')).to.not.be.ok();
$('.apple').toggleClass('apple red');
expect($('.fruit').hasClass('apple')).to.not.be.ok();
expect($('.fruit').hasClass('red')).to.be.ok();
expect($('.fruit').hasClass('fruit')).to.be.ok();
});
it('(class class, true) : should add multiple classes to the element', function() {
$('.apple').addClass('fruit');
expect($('.apple').hasClass('apple')).to.be.ok();
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.apple').hasClass('red')).to.not.be.ok();
$('.apple').toggleClass('apple red', true);
expect($('.fruit').hasClass('apple')).to.be.ok();
expect($('.fruit').hasClass('red')).to.be.ok();
expect($('.fruit').hasClass('fruit')).to.be.ok();
});
it('(class true) : should add only one instance of class', function () {
$('.apple').toggleClass('tasty', true);
$('.apple').toggleClass('tasty', true);
expect($('.apple').attr('class').match(/tasty/g).length).to.equal(1);
});
it('(class class, false) : should remove multiple classes from the element', function() {
$('.apple').addClass('fruit');
expect($('.apple').hasClass('apple')).to.be.ok();
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.apple').hasClass('red')).to.not.be.ok();
$('.apple').toggleClass('apple red', false);
expect($('.fruit').hasClass('apple')).to.not.be.ok();
expect($('.fruit').hasClass('red')).to.not.be.ok();
expect($('.fruit').hasClass('fruit')).to.be.ok();
});
it('(fn) : should toggle classes returned from the function', function() {
$ = cheerio.load(food);
$('.apple').addClass('fruit');
$('.carrot').addClass('vegetable');
expect($('.apple').hasClass('fruit')).to.be.ok();
expect($('.apple').hasClass('vegetable')).to.not.be.ok();
expect($('.orange').hasClass('fruit')).to.not.be.ok();
expect($('.orange').hasClass('vegetable')).to.not.be.ok();
expect($('.carrot').hasClass('fruit')).to.not.be.ok();
expect($('.carrot').hasClass('vegetable')).to.be.ok();
expect($('.sweetcorn').hasClass('fruit')).to.not.be.ok();
expect($('.sweetcorn').hasClass('vegetable')).to.not.be.ok();
$('li').toggleClass(function() {
return $(this).parent().is('#fruits') ? 'fruit' : 'vegetable';
});
expect($('.apple').hasClass('fruit')).to.not.be.ok();
expect($('.apple').hasClass('vegetable')).to.not.be.ok();
expect($('.orange').hasClass('fruit')).to.be.ok();
expect($('.orange').hasClass('vegetable')).to.not.be.ok();
expect($('.carrot').hasClass('fruit')).to.not.be.ok();
expect($('.carrot').hasClass('vegetable')).to.not.be.ok();
expect($('.sweetcorn').hasClass('fruit')).to.not.be.ok();
expect($('.sweetcorn').hasClass('vegetable')).to.be.ok();
});
});
describe('.is', function () {
it('() : should return false', function() {
expect($('li.apple').is()).to.be(false);
});
it('(true selector) : should return true', function() {
expect(cheerio('#vegetables', vegetables).is('ul')).to.be(true);
});
it('(false selector) : should return false', function() {
expect(cheerio('#vegetables', vegetables).is('div')).to.be(false);
});
it('(true selection) : should return true', function() {
var $vegetables = cheerio('li', vegetables);
expect($vegetables.is($vegetables.eq(1))).to.be(true);
});
it('(false selection) : should return false', function() {
var $vegetableList = cheerio(vegetables);
var $vegetables = $vegetableList.find('li');
expect($vegetables.is($vegetableList)).to.be(false);
});
it('(true element) : should return true', function() {
var $vegetables = cheerio('li', vegetables);
expect($vegetables.is($vegetables[0])).to.be(true);
});
it('(false element) : should return false', function() {
var $vegetableList = cheerio(vegetables);
var $vegetables = $vegetableList.find('li');
expect($vegetables.is($vegetableList[0])).to.be(false);
});
it('(true predicate) : should return true', function() {
var result = $('li').is(function() {
return this.tagName === 'li' && $(this).hasClass('pear');
});
expect(result).to.be(true);
});
it('(false predicate) : should return false', function () {
var result = $('li').last().is(function() {
return this.tagName === 'ul';
});
expect(result).to.be(false);
});
});
});

88
node_modules/cheerio/test/api/css.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
var expect = require('expect.js');
var cheerio = require('../..');
describe('$(...)', function() {
describe('.css', function() {
it('(prop): should return a css property value', function() {
var el = cheerio('<li style="hai: there">');
expect(el.css('hai')).to.equal('there');
});
it('([prop1, prop2]): should return the specified property values as an object', function() {
var el = cheerio('<li style="margin: 1px; padding: 2px; color: blue;">');
expect(el.css(['margin', 'color'])).to.eql({ margin: '1px', color: 'blue' });
});
it('(prop, val): should set a css property', function() {
var el = cheerio('<li style="margin: 0;"></li><li></li>');
el.css('color', 'red');
expect(el.attr('style')).to.equal('margin: 0; color: red;');
expect(el.eq(1).attr('style')).to.equal('color: red;');
});
it('(prop, ""): should unset a css property', function() {
var el = cheerio('<li style="padding: 1px; margin: 0;">');
el.css('padding', '');
expect(el.attr('style')).to.equal('margin: 0;');
});
it('(prop): should not mangle embedded urls', function() {
var el = cheerio('<li style="background-image:url(http://example.com/img.png);">');
expect(el.css('background-image')).to.equal('url(http://example.com/img.png)');
});
it('(prop): should ignore blank properties', function() {
var el = cheerio('<li style=":#ccc;color:#aaa;">');
expect(el.css()).to.eql({color:'#aaa'});
});
it('(prop): should ignore blank values', function() {
var el = cheerio('<li style="color:;position:absolute;">');
expect(el.css()).to.eql({position:'absolute'});
});
describe('(prop, function):', function() {
beforeEach(function() {
this.$el = cheerio('<div style="margin: 0px;"></div><div style="margin: 1px;"></div><div style="margin: 2px;">');
});
it('should iterate over the selection', function() {
var count = 0;
var $el = this.$el;
this.$el.css('margin', function(idx, value) {
expect(idx).to.equal(count);
expect(value).to.equal(count + 'px');
expect(this).to.equal($el[count]);
count++;
});
expect(count).to.equal(3);
});
it('should set each attribute independently', function() {
var values = ['4px', '', undefined];
this.$el.css('margin', function(idx) {
return values[idx];
});
expect(this.$el.eq(0).attr('style')).to.equal('margin: 4px;');
expect(this.$el.eq(1).attr('style')).to.equal('');
expect(this.$el.eq(2).attr('style')).to.equal('margin: 2px;');
});
});
it('(obj): should set each key and val', function() {
var el = cheerio('<li style="padding: 0;"></li><li></li>');
el.css({ foo: 0 });
expect(el.eq(0).attr('style')).to.equal('padding: 0; foo: 0;');
expect(el.eq(1).attr('style')).to.equal('foo: 0;');
});
describe('parser', function(){
it('should allow any whitespace between declarations', function() {
var el = cheerio('<li style="one \t:\n 0;\n two \f\r:\v 1">');
expect(el.css(['one', 'two'])).to.eql({ one: 0, two: 1 });
});
});
});
});

120
node_modules/cheerio/test/api/forms.js generated vendored Normal file
View File

@ -0,0 +1,120 @@
var expect = require('expect.js'),
cheerio = require('../..'),
forms = require('../fixtures').forms;
describe('$(...)', function() {
var $;
beforeEach(function() {
$ = cheerio.load(forms);
});
describe('.serializeArray', function() {
it('() : should get form controls', function() {
expect($('form#simple').serializeArray()).to.eql([
{
name: 'fruit',
value: 'Apple'
}
]);
});
it('() : should get nested form controls', function() {
expect($('form#nested').serializeArray()).to.have.length(2);
var data = $('form#nested').serializeArray();
data.sort(function (a, b) {
return a.value - b.value;
});
expect(data).to.eql([
{
name: 'fruit',
value: 'Apple'
},
{
name: 'vegetable',
value: 'Carrot'
}
]);
});
it('() : should not get disabled form controls', function() {
expect($('form#disabled').serializeArray()).to.eql([]);
});
it('() : should not get form controls with the wrong type', function() {
expect($('form#submit').serializeArray()).to.eql([
{
name: 'fruit',
value: 'Apple'
}
]);
});
it('() : should get selected options', function() {
expect($('form#select').serializeArray()).to.eql([
{
name: 'fruit',
value: 'Orange'
}
]);
});
it('() : should not get unnamed form controls', function() {
expect($('form#unnamed').serializeArray()).to.eql([
{
name: 'fruit',
value: 'Apple'
}
]);
});
it('() : should get multiple selected options', function() {
expect($('form#multiple').serializeArray()).to.have.length(2);
var data = $('form#multiple').serializeArray();
data.sort(function (a, b) {
return a.value - b.value;
});
expect(data).to.eql([
{
name: 'fruit',
value: 'Apple'
},
{
name: 'fruit',
value: 'Orange'
}
]);
});
it('() : should get individually selected elements', function() {
var data = $('form#nested input').serializeArray();
data.sort(function (a, b) {
return a.value - b.value;
});
expect(data).to.eql([
{
name: 'fruit',
value: 'Apple'
},
{
name: 'vegetable',
value: 'Carrot'
}
]);
});
it('() : should standardize line breaks', function() {
expect($('form#textarea').serializeArray()).to.eql([
{
name: 'fruits',
value: 'Apple\r\nOrange'
}
]);
});
});
});

1265
node_modules/cheerio/test/api/manipulation.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1408
node_modules/cheerio/test/api/traversing.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

211
node_modules/cheerio/test/api/utils.js generated vendored Normal file
View File

@ -0,0 +1,211 @@
var expect = require('expect.js'),
fixtures = require('../fixtures'),
cheerio = require('../..');
describe('cheerio', function() {
describe('.html', function() {
it('() : should return innerHTML; $.html(obj) should return outerHTML', function() {
var $div = cheerio('div', '<div><span>foo</span><span>bar</span></div>');
var span = $div.children()[1];
expect(cheerio(span).html()).to.equal('bar');
expect(cheerio.html(span)).to.equal('<span>bar</span>');
});
it('(<obj>) : should accept an object, an array, or a cheerio object', function() {
var $span = cheerio('<span>foo</span>');
expect(cheerio.html($span[0])).to.equal('<span>foo</span>');
expect(cheerio.html($span)).to.equal('<span>foo</span>');
});
it('(<value>) : should be able to set to an empty string', function() {
var $elem = cheerio('<span>foo</span>').html('');
expect(cheerio.html($elem)).to.equal('<span></span>');
});
it('() : of empty cheerio object should return null', function() {
expect(cheerio().html()).to.be(null);
});
it('(selector) : should return the outerHTML of the selected element', function() {
var $ = cheerio.load(fixtures.fruits);
expect($.html('.pear')).to.equal('<li class="pear">Pear</li>');
});
});
describe('.load', function() {
it('(html) : should retain original root after creating a new node', function() {
var $html = cheerio.load('<body><ul id="fruits"></ul></body>');
expect($html('body')).to.have.length(1);
$html('<script>');
expect($html('body')).to.have.length(1);
});
it('(html) : should handle lowercase tag options', function() {
var $html = cheerio.load('<BODY><ul id="fruits"></ul></BODY>', { lowerCaseTags : true });
expect($html.html()).to.be('<body><ul id="fruits"></ul></body>');
});
it('(html) : should handle the `normalizeWhitepace` option', function() {
var $html = cheerio.load('<body><b>foo</b> <b>bar</b></body>', { normalizeWhitespace : true });
expect($html.html()).to.be('<body><b>foo</b> <b>bar</b></body>');
});
// TODO:
// it('(html) : should handle xml tag option', function() {
// var $html = $.load('<body><script>oh hai</script></body>', { xmlMode : true });
// console.log($html('script')[0].type);
// expect($html('script')[0].type).to.be('tag');
// });
it('(buffer) : should accept a buffer', function() {
var $html = cheerio.load(new Buffer('<div>foo</div>'));
expect($html.html()).to.be('<div>foo</div>');
});
});
describe('.clone', function() {
it('() : should return a copy', function() {
var $src = cheerio('<div><span>foo</span><span>bar</span><span>baz</span></div>').children();
var $elem = $src.clone();
expect($elem.length).to.equal(3);
expect($elem.parent()).to.have.length(0);
expect($elem.text()).to.equal($src.text());
$src.text('rofl');
expect($elem.text()).to.not.equal($src.text());
});
it('() : should preserve parsing options', function() {
var $ = cheerio.load('<div>π</div>', { decodeEntities: false });
var $div = $('div');
expect($div.text()).to.equal($div.clone().text());
});
});
describe('.parseHTML', function() {
it('() : returns null', function() {
expect(cheerio.parseHTML()).to.equal(null);
});
it('(null) : returns null', function() {
expect(cheerio.parseHTML(null)).to.equal(null);
});
it('("") : returns null', function() {
expect(cheerio.parseHTML('')).to.equal(null);
});
it('(largeHtmlString) : parses large HTML strings', function() {
var html = new Array(10).join('<div></div>');
var nodes = cheerio.parseHTML(html);
expect(nodes.length).to.be.greaterThan(4);
expect(nodes).to.be.an('array');
});
it('("<script>") : ignores scripts by default', function() {
var html = '<script>undefined()</script>';
expect(cheerio.parseHTML(html)).to.have.length(0);
});
it('("<script>", true) : preserves scripts when requested', function() {
var html = '<script>undefined()</script>';
expect(cheerio.parseHTML(html, true)[0].tagName).to.match(/script/i);
});
it('("scriptAndNonScript) : preserves non-script nodes', function() {
var html = '<script>undefined()</script><div></div>';
expect(cheerio.parseHTML(html)[0].tagName).to.match(/div/i);
});
it('(scriptAndNonScript, true) : Preserves script position', function() {
var html = '<script>undefined()</script><div></div>';
expect(cheerio.parseHTML(html, true)[0].tagName).to.match(/script/i);
});
it('(text) : returns a text node', function() {
expect(cheerio.parseHTML('text')[0].type).to.be('text');
});
it('(\\ttext) : preserves leading whitespace', function() {
expect(cheerio.parseHTML('\t<div></div>')[0].data).to.equal('\t');
});
it('( text) : Leading spaces are treated as text nodes', function() {
expect(cheerio.parseHTML(' <div/> ')[0].type).to.be('text');
});
it('(html) : should preserve content', function() {
var html = '<div>test div</div>';
expect(cheerio(cheerio.parseHTML(html)[0]).html()).to.equal('test div');
});
it('(malformedHtml) : should not break', function() {
expect(cheerio.parseHTML('<span><span>')).to.have.length(1);
});
it('(garbageInput) : should not cause an error', function() {
expect(cheerio.parseHTML('<#if><tr><p>This is a test.</p></tr><#/if>') || true).to.be.ok();
});
it('(text) : should return an array that is not effected by DOM manipulation methods', function() {
var $ = cheerio.load('<div>');
var elems = $.parseHTML('<b></b><i></i>');
$('div').append(elems);
expect(elems).to.have.length(2);
});
});
describe('.contains', function() {
var $;
beforeEach(function() {
$ = cheerio.load(fixtures.food);
});
it('(container, contained) : should correctly detect the provided element', function() {
var $food = $('#food');
var $fruits = $('#fruits');
var $apple = $('.apple');
expect($.contains($food[0], $fruits[0])).to.equal(true);
expect($.contains($food[0], $apple[0])).to.equal(true);
});
it('(container, other) : should not detect elements that are not contained', function() {
var $fruits = $('#fruits');
var $vegetables = $('#vegetables');
var $apple = $('.apple');
expect($.contains($vegetables[0], $apple[0])).to.equal(false);
expect($.contains($fruits[0], $vegetables[0])).to.equal(false);
expect($.contains($vegetables[0], $fruits[0])).to.equal(false);
expect($.contains($fruits[0], $fruits[0])).to.equal(false);
expect($.contains($vegetables[0], $vegetables[0])).to.equal(false);
});
});
describe('.root', function() {
it('() : should return a cheerio-wrapped root object', function() {
var $html = cheerio.load('<div><span>foo</span><span>bar</span></div>');
$html.root().append('<div id="test"></div>');
expect($html.html()).to.equal('<div><span>foo</span><span>bar</span></div><div id="test"></div>');
});
});
});

340
node_modules/cheerio/test/cheerio.js generated vendored Normal file
View File

@ -0,0 +1,340 @@
var expect = require('expect.js'),
_ = require('lodash'),
htmlparser2 = require('htmlparser2'),
$ = require('../'),
fixtures = require('./fixtures'),
fruits = fixtures.fruits,
food = fixtures.food;
// HTML
var script = '<script src="script.js" type="text/javascript"></script>',
multiclass = '<p><a class="btn primary" href="#">Save</a></p>';
describe('cheerio', function() {
it('should get the version', function() {
expect(/\d+\.\d+\.\d+/.test($.version)).to.be.ok();
});
it('$(null) should return be empty', function() {
expect($(null)).to.be.empty();
});
it('$(undefined) should be empty', function() {
expect($(undefined)).to.be.empty();
});
it('$(null) should be empty', function() {
expect($('')).to.be.empty();
});
it('$(selector) with no context or root should be empty', function() {
expect($('.h2')).to.be.empty();
expect($('#fruits')).to.be.empty();
});
it('$(node) : should override previously-loaded nodes', function() {
var C = $.load('<div><span></span></div>');
var spanNode = C('span')[0];
var $span = C(spanNode);
expect($span[0]).to.equal(spanNode);
});
it('should be able to create html without a root or context', function() {
var $h2 = $('<h2>');
expect($h2).to.not.be.empty();
expect($h2).to.have.length(1);
expect($h2[0].tagName).to.equal('h2');
});
it('should be able to create complicated html', function() {
var $script = $(script);
expect($script).to.not.be.empty();
expect($script).to.have.length(1);
expect($script[0].attribs.src).to.equal('script.js');
expect($script[0].attribs.type).to.equal('text/javascript');
expect($script[0].childNodes).to.be.empty();
});
var testAppleSelect = function($apple) {
expect($apple).to.have.length(1);
$apple = $apple[0];
expect($apple.parentNode.tagName).to.equal('ul');
expect($apple.prev).to.be(null);
expect($apple.next.attribs['class']).to.equal('orange');
expect($apple.childNodes).to.have.length(1);
expect($apple.childNodes[0].data).to.equal('Apple');
};
it('should be able to select .apple with only a context', function() {
var $apple = $('.apple', fruits);
testAppleSelect($apple);
});
it('should be able to select .apple with a node as context', function() {
var $apple = $('.apple', $(fruits)[0]);
testAppleSelect($apple);
});
it('should be able to select .apple with only a root', function() {
var $apple = $('.apple', null, fruits);
testAppleSelect($apple);
});
it('should be able to select an id', function() {
var $fruits = $('#fruits', null, fruits);
expect($fruits).to.have.length(1);
expect($fruits[0].attribs.id).to.equal('fruits');
});
it('should be able to select a tag', function() {
var $ul = $('ul', fruits);
expect($ul).to.have.length(1);
expect($ul[0].tagName).to.equal('ul');
});
it('should accept a node reference as a context', function() {
var $elems = $('<div><span></span></div>');
expect($('span', $elems[0])).to.have.length(1);
});
it('should accept an array of node references as a context', function() {
var $elems = $('<div><span></span></div>');
expect($('span', $elems.toArray())).to.have.length(1);
});
it('should select only elements inside given context (Issue #193)', function() {
var q = $.load(food),
fruits = q('#fruits'),
fruitElements = q('li', fruits);
expect(fruitElements).to.have.length(3);
});
it('should be able to select multiple tags', function() {
var $fruits = $('li', null, fruits);
expect($fruits).to.have.length(3);
var classes = ['apple', 'orange', 'pear'];
$fruits.each(function(idx, $fruit) {
expect($fruit.attribs['class']).to.equal(classes[idx]);
});
});
it('should be able to do: $("#fruits .apple")', function() {
var $apple = $('#fruits .apple', fruits);
testAppleSelect($apple);
});
it('should be able to do: $("li.apple")', function() {
var $apple = $('li.apple', fruits);
testAppleSelect($apple);
});
it('should be able to select by attributes', function() {
var $apple = $('li[class=apple]', fruits);
testAppleSelect($apple);
});
it('should be able to select multiple classes: $(".btn.primary")', function() {
var $a = $('.btn.primary', multiclass);
expect($a).to.have.length(1);
expect($a[0].childNodes[0].data).to.equal('Save');
});
it('should not create a top-level node', function() {
var $elem = $('* div', '<div>');
expect($elem).to.have.length(0);
});
it('should be able to select multiple elements: $(".apple, #fruits")', function() {
var $elems = $('.apple, #fruits', fruits);
expect($elems).to.have.length(2);
var $apple = _.filter($elems, function(elem) {
return elem.attribs['class'] === 'apple';
});
var $fruits = _.filter($elems, function(elem) {
return elem.attribs.id === 'fruits';
});
testAppleSelect($apple);
expect($fruits[0].attribs.id).to.equal('fruits');
});
it('should select first element $(:first)');
// var $elem = $(':first', fruits);
// var $h2 = $('<h2>fruits</h2>');
// console.log($elem.before('hi'));
// console.log($elem.before($h2));
it('should be able to select immediate children: $("#fruits > .pear")', function() {
var $food = $(food);
$('.pear', $food).append('<li class="pear">Another Pear!</li>');
expect($('#fruits .pear', $food)).to.have.length(2);
var $elem = $('#fruits > .pear', $food);
expect($elem).to.have.length(1);
expect($elem.attr('class')).to.equal('pear');
});
it('should be able to select immediate children: $(".apple + .pear")', function() {
var $elem = $('.apple + li', fruits);
expect($elem).to.have.length(1);
$elem = $('.apple + .pear', fruits);
expect($elem).to.have.length(0);
$elem = $('.apple + .orange', fruits);
expect($elem).to.have.length(1);
expect($elem.attr('class')).to.equal('orange');
});
it('should be able to select immediate children: $(".apple ~ .pear")', function() {
var $elem = $('.apple ~ li', fruits);
expect($elem).to.have.length(2);
$elem = $('.apple ~ .pear', fruits);
expect($elem.attr('class')).to.equal('pear');
});
it('should handle wildcards on attributes: $("li[class*=r]")', function() {
var $elem = $('li[class*=r]', fruits);
expect($elem).to.have.length(2);
expect($elem.eq(0).attr('class')).to.equal('orange');
expect($elem.eq(1).attr('class')).to.equal('pear');
});
it('should handle beginning of attr selectors: $("li[class^=o]")', function() {
var $elem = $('li[class^=o]', fruits);
expect($elem).to.have.length(1);
expect($elem.eq(0).attr('class')).to.equal('orange');
});
it('should handle beginning of attr selectors: $("li[class$=e]")', function() {
var $elem = $('li[class$=e]', fruits);
expect($elem).to.have.length(2);
expect($elem.eq(0).attr('class')).to.equal('apple');
expect($elem.eq(1).attr('class')).to.equal('orange');
});
it('should gracefully degrade on complex, unmatched queries', function() {
var $elem = $('Eastern States Cup #8-fin&nbsp;<br>Downhill&nbsp;');
expect($elem).to.have.length(0); // []
});
it('(extended Array) should not interfere with prototype methods (issue #119)', function() {
var extended = [];
extended.find = extended.children = extended.each = function() {};
var $empty = $(extended);
expect($empty.find).to.be($.prototype.find);
expect($empty.children).to.be($.prototype.children);
expect($empty.each).to.be($.prototype.each);
});
describe('.load', function() {
it('should generate selections as proper instances', function() {
var q = $.load(fruits);
expect(q('.apple')).to.be.a(q);
});
it('should be able to filter down using the context', function() {
var q = $.load(fruits),
apple = q('.apple', 'ul'),
lis = q('li', 'ul');
expect(apple).to.have.length(1);
expect(lis).to.have.length(3);
});
it('should allow loading a pre-parsed DOM', function() {
var dom = htmlparser2.parseDOM(food),
q = $.load(dom);
expect(q('ul')).to.have.length(3);
});
it('should render xml in html() when options.xmlMode = true', function() {
var str = '<MixedCaseTag UPPERCASEATTRIBUTE=""></MixedCaseTag>',
expected = '<MixedCaseTag UPPERCASEATTRIBUTE=""/>',
dom = $.load(str, {xmlMode: true});
expect(dom('MixedCaseTag').get(0).tagName).to.equal('MixedCaseTag');
expect(dom.html()).to.be(expected);
});
it('should render xml in html() when options.xmlMode = true passed to html()', function() {
var str = '<MixedCaseTag UPPERCASEATTRIBUTE=""></MixedCaseTag>',
// since parsing done without xmlMode flag, all tags converted to lowercase
expectedXml = '<mixedcasetag uppercaseattribute=""/>',
expectedNoXml = '<mixedcasetag uppercaseattribute=""></mixedcasetag>',
dom = $.load(str);
expect(dom('MixedCaseTag').get(0).tagName).to.equal('mixedcasetag');
expect(dom.html()).to.be(expectedNoXml);
expect(dom.html({xmlMode: true})).to.be(expectedXml);
});
it('should respect options on the element level', function() {
var str = '<!doctype html><html><head><title>Some test</title></head><body><footer><p>Copyright &copy; 2003-2014</p></footer></body></html>',
expectedHtml = '<p>Copyright &copy; 2003-2014</p>',
expectedXml = '<p>Copyright &#xA9; 2003-2014</p>',
domNotEncoded = $.load(str, {decodeEntities: false}),
domEncoded = $.load(str);
expect(domNotEncoded('footer').html()).to.be(expectedHtml);
// TODO: Make it more html friendly, maybe with custom encode tables
expect(domEncoded('footer').html()).to.be(expectedXml);
});
it('should return a fully-qualified Function', function() {
var $c = $.load('<div>');
expect($c).to.be.a(Function);
});
describe('prototype extensions', function() {
it('should honor extensions defined on `prototype` property', function() {
var $c = $.load('<div>');
var $div;
$c.prototype.myPlugin = function() {
return {
context: this,
args: arguments
};
};
$div = $c('div');
expect($div.myPlugin).to.be.a('function');
expect($div.myPlugin().context).to.be($div);
expect(Array.prototype.slice.call($div.myPlugin(1, 2, 3).args))
.to.eql([1, 2, 3]);
});
it('should honor extensions defined on `fn` property', function() {
var $c = $.load('<div>');
var $div;
$c.fn.myPlugin = function() {
return {
context: this,
args: arguments
};
};
$div = $c('div');
expect($div.myPlugin).to.be.a('function');
expect($div.myPlugin().context).to.be($div);
expect(Array.prototype.slice.call($div.myPlugin(1, 2, 3).args))
.to.eql([1, 2, 3]);
});
it('should isolate extensions between loaded functions', function() {
var $a = $.load('<div>');
var $b = $.load('<div>');
$a.prototype.foo = function() {};
expect($b('div').foo).to.be(undefined);
});
});
});
});

65
node_modules/cheerio/test/fixtures.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
/* jshint indent: false */
exports.fruits = [
'<ul id="fruits">',
'<li class="apple">Apple</li>',
'<li class="orange">Orange</li>',
'<li class="pear">Pear</li>',
'</ul>'
].join('');
exports.vegetables = [
'<ul id="vegetables">',
'<li class="carrot">Carrot</li>',
'<li class="sweetcorn">Sweetcorn</li>',
'</ul>'
].join('');
exports.chocolates = [
'<ul id="chocolates">',
'<li class="linth" data-highlight="Lindor" data-origin="swiss">Linth</li>',
'<li class="frey" data-taste="sweet" data-best-collection="Mahony">Frey</li>',
'<li class="cailler">Cailler</li>',
'</ul>'
].join('');
exports.drinks = [
'<ul id="drinks">',
'<li class="beer">Beer</li>',
'<li class="juice">Juice</li>',
'<li class="milk">Milk</li>',
'<li class="water">Water</li>',
'<li class="cider">Cider</li>',
'</ul>'
].join('');
exports.food = [
'<ul id="food">',
exports.fruits,
exports.vegetables,
'</ul>'
].join('');
exports.inputs = [
'<select id="one"><option value="option_not_selected">Option not selected</option><option value="option_selected" selected>Option selected</option></select>',
'<input type="text" value="input_text" />',
'<input type="checkbox" name="checkbox_off" value="off" /><input type="checkbox" name="checkbox_on" value="on" checked />',
'<input type="radio" value="off" name="radio" /><input type="radio" name="radio" value="on" checked />',
'<input type="radio" value="off" name="radio[brackets]" /><input type="radio" name="radio[brackets]" value="on" checked />',
'<select id="multi" multiple><option value="1">1</option><option value="2" selected>2</option><option value="3" selected>3</option><option value="4">4</option></select>'
].join('');
exports.text = [
'<p>Apples, <b>oranges</b> and pears.</p>',
'<p>Carrots and <!-- sweetcorn --></p>'
].join('');
exports.forms = [
'<form id="simple"><input type="text" name="fruit" value="Apple" /></form>',
'<form id="nested"><div><input type="text" name="fruit" value="Apple" /></div><input type="text" name="vegetable" value="Carrot" /></form>',
'<form id="disabled"><input type="text" name="fruit" value="Apple" disabled /></form>',
'<form id="submit"><input type="text" name="fruit" value="Apple" /><input type="submit" name="submit" value="Submit" /></form>',
'<form id="select"><select name="fruit"><option value="Apple">Apple</option><option value="Orange" selected>Orange</option></select></form>',
'<form id="unnamed"><input type="text" name="fruit" value="Apple" /><input type="text" value="Carrot" /></form>',
'<form id="multiple"><select name="fruit" multiple><option value="Apple" selected>Apple</option><option value="Orange" selected>Orange</option><option value="Carrot">Carrot</option></select></form>',
'<form id="textarea"><textarea name="fruits">Apple\nOrange</textarea></form>'
].join('');

2
node_modules/cheerio/test/mocha.opts generated vendored Normal file
View File

@ -0,0 +1,2 @@
--reporter list
--growl

252
node_modules/cheerio/test/parse.js generated vendored Normal file
View File

@ -0,0 +1,252 @@
var expect = require('expect.js'),
parse = require('../lib/parse'),
defaultOpts = require('..').prototype.options;
// Tags
var basic = '<html></html>';
var siblings = '<h2></h2><p></p>';
// Single Tags
var single = '<br/>';
var singleWrong = '<br>';
// Children
var children = '<html><br/></html>';
var li = '<li class="durian">Durian</li>';
// Attributes
var attributes = '<img src="hello.png" alt="man waving">';
var noValueAttribute = '<textarea disabled></textarea>';
// Comments
var comment = '<!-- sexy -->';
var conditional = '<!--[if IE 8]><html class="no-js ie8" lang="en"><![endif]-->';
// Text
var text = 'lorem ipsum';
// Script
var script = '<script type="text/javascript">alert("hi world!");</script>';
var scriptEmpty = '<script></script>';
// Style
var style = '<style type="text/css"> h2 { color:blue; } </style>';
var styleEmpty = '<style></style>';
// Directives
var directive = '<!doctype html>';
describe('parse', function() {
describe('.eval', function() {
it('should parse basic empty tags: ' + basic, function() {
var tag = parse.evaluate(basic, defaultOpts)[0];
expect(tag.type).to.equal('tag');
expect(tag.tagName).to.equal('html');
expect(tag.childNodes).to.be.empty();
});
it('should handle sibling tags: ' + siblings, function() {
var dom = parse.evaluate(siblings, defaultOpts),
h2 = dom[0],
p = dom[1];
expect(dom).to.have.length(2);
expect(h2.tagName).to.equal('h2');
expect(p.tagName).to.equal('p');
});
it('should handle single tags: ' + single, function() {
var tag = parse.evaluate(single, defaultOpts)[0];
expect(tag.type).to.equal('tag');
expect(tag.tagName).to.equal('br');
expect(tag.childNodes).to.be.empty();
});
it('should handle malformatted single tags: ' + singleWrong, function() {
var tag = parse.evaluate(singleWrong, defaultOpts)[0];
expect(tag.type).to.equal('tag');
expect(tag.tagName).to.equal('br');
expect(tag.childNodes).to.be.empty();
});
it('should handle tags with children: ' + children, function() {
var tag = parse.evaluate(children, defaultOpts)[0];
expect(tag.type).to.equal('tag');
expect(tag.tagName).to.equal('html');
expect(tag.childNodes).to.be.ok();
expect(tag.childNodes).to.have.length(1);
});
it('should handle tags with children: ' + li, function() {
var tag = parse.evaluate(li, defaultOpts)[0];
expect(tag.childNodes).to.have.length(1);
expect(tag.childNodes[0].data).to.equal('Durian');
});
it('should handle tags with attributes: ' + attributes, function() {
var attrs = parse.evaluate(attributes, defaultOpts)[0].attribs;
expect(attrs).to.be.ok();
expect(attrs.src).to.equal('hello.png');
expect(attrs.alt).to.equal('man waving');
});
it('should handle value-less attributes: ' + noValueAttribute, function() {
var attrs = parse.evaluate(noValueAttribute, defaultOpts)[0].attribs;
expect(attrs).to.be.ok();
expect(attrs.disabled).to.equal('');
});
it('should handle comments: ' + comment, function() {
var elem = parse.evaluate(comment, defaultOpts)[0];
expect(elem.type).to.equal('comment');
expect(elem.data).to.equal(' sexy ');
});
it('should handle conditional comments: ' + conditional, function() {
var elem = parse.evaluate(conditional, defaultOpts)[0];
expect(elem.type).to.equal('comment');
expect(elem.data).to.equal(conditional.replace('<!--', '').replace('-->', ''));
});
it('should handle text: ' + text, function() {
var text_ = parse.evaluate(text, defaultOpts)[0];
expect(text_.type).to.equal('text');
expect(text_.data).to.equal('lorem ipsum');
});
it('should handle script tags: ' + script, function() {
var script_ = parse.evaluate(script, defaultOpts)[0];
expect(script_.type).to.equal('script');
expect(script_.tagName).to.equal('script');
expect(script_.attribs.type).to.equal('text/javascript');
expect(script_.childNodes).to.have.length(1);
expect(script_.childNodes[0].type).to.equal('text');
expect(script_.childNodes[0].data).to.equal('alert("hi world!");');
});
it('should handle style tags: ' + style, function() {
var style_ = parse.evaluate(style, defaultOpts)[0];
expect(style_.type).to.equal('style');
expect(style_.tagName).to.equal('style');
expect(style_.attribs.type).to.equal('text/css');
expect(style_.childNodes).to.have.length(1);
expect(style_.childNodes[0].type).to.equal('text');
expect(style_.childNodes[0].data).to.equal(' h2 { color:blue; } ');
});
it('should handle directives: ' + directive, function() {
var elem = parse.evaluate(directive, defaultOpts)[0];
expect(elem.type).to.equal('directive');
expect(elem.data).to.equal('!doctype html');
expect(elem.tagName).to.equal('!doctype');
});
});
describe('.parse', function() {
// root test utility
function rootTest(root) {
expect(root.tagName).to.equal('root');
// Should exist but be null
expect(root.nextSibling).to.be(null);
expect(root.previousSibling).to.be(null);
expect(root.parentNode).to.be(null);
var child = root.childNodes[0];
expect(child.parentNode).to.be(null);
}
it('should add root to: ' + basic, function() {
var root = parse(basic, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(1);
expect(root.childNodes[0].tagName).to.equal('html');
});
it('should add root to: ' + siblings, function() {
var root = parse(siblings, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(2);
expect(root.childNodes[0].tagName).to.equal('h2');
expect(root.childNodes[1].tagName).to.equal('p');
expect(root.childNodes[1].parent).to.equal(null);
});
it('should add root to: ' + comment, function() {
var root = parse(comment, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(1);
expect(root.childNodes[0].type).to.equal('comment');
});
it('should add root to: ' + text, function() {
var root = parse(text, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(1);
expect(root.childNodes[0].type).to.equal('text');
});
it('should add root to: ' + scriptEmpty, function() {
var root = parse(scriptEmpty, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(1);
expect(root.childNodes[0].type).to.equal('script');
});
it('should add root to: ' + styleEmpty, function() {
var root = parse(styleEmpty, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(1);
expect(root.childNodes[0].type).to.equal('style');
});
it('should add root to: ' + directive, function() {
var root = parse(directive, defaultOpts);
rootTest(root);
expect(root.childNodes).to.have.length(1);
expect(root.childNodes[0].type).to.equal('directive');
});
it('should expose the DOM level 1 API', function() {
var root = parse('<div><a></a><span></span><p></p></div>', defaultOpts).childNodes[0];
var childNodes = root.childNodes;
expect(childNodes).to.have.length(3);
expect(root.tagName).to.be('div');
expect(root.firstChild).to.be(childNodes[0]);
expect(root.lastChild).to.be(childNodes[2]);
expect(childNodes[0].tagName).to.be('a');
expect(childNodes[0].previousSibling).to.be(null);
expect(childNodes[0].nextSibling).to.be(childNodes[1]);
expect(childNodes[0].parentNode).to.be(root);
expect(childNodes[0].childNodes).to.have.length(0);
expect(childNodes[0].firstChild).to.be(null);
expect(childNodes[0].lastChild).to.be(null);
expect(childNodes[1].tagName).to.be('span');
expect(childNodes[1].previousSibling).to.be(childNodes[0]);
expect(childNodes[1].nextSibling).to.be(childNodes[2]);
expect(childNodes[1].parentNode).to.be(root);
expect(childNodes[1].childNodes).to.have.length(0);
expect(childNodes[1].firstChild).to.be(null);
expect(childNodes[1].lastChild).to.be(null);
expect(childNodes[2].tagName).to.be('p');
expect(childNodes[2].previousSibling).to.be(childNodes[1]);
expect(childNodes[2].nextSibling).to.be(null);
expect(childNodes[2].parentNode).to.be(root);
expect(childNodes[2].childNodes).to.have.length(0);
expect(childNodes[2].firstChild).to.be(null);
expect(childNodes[2].lastChild).to.be(null);
});
});
});

58
node_modules/cheerio/test/xml.js generated vendored Normal file
View File

@ -0,0 +1,58 @@
var expect = require('expect.js'),
_ = require('lodash'),
cheerio = require('..');
var xml = function(str, options) {
options = _.extend({ xmlMode: true }, options);
var dom = cheerio.load(str, options);
return dom.xml();
};
var dom = function(str, options) {
var $ = cheerio.load('', options);
return $(str).html();
};
describe('render', function() {
describe('(xml)', function() {
it('should render <media:thumbnail /> tags correctly', function() {
var str = '<media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123" />';
expect(xml(str)).to.equal('<media:thumbnail url="http://www.foo.com/keyframe.jpg" width="75" height="50" time="12:05:01.123"/>');
});
it('should render <link /> tags (RSS) correctly', function() {
var str = '<link>http://www.github.com/</link>';
expect(xml(str)).to.equal('<link>http://www.github.com/</link>');
});
it('should escape entities', function(){
var str = '<tag attr="foo &amp; bar"/>';
expect(xml(str)).to.equal(str);
});
});
describe('(dom)', function () {
it('should keep camelCase for new nodes', function() {
var str = '<g><someElem someAttribute="something">hello</someElem></g>';
expect(dom(str, {xmlMode: false})).to.equal('<someelem someattribute="something">hello</someelem>');
});
it('should keep camelCase for new nodes', function() {
var str = '<g><someElem someAttribute="something">hello</someElem></g>';
expect(dom(str, {xmlMode: true})).to.equal('<someElem someAttribute="something">hello</someElem>');
});
it('should maintain the parsing options of distinct contexts independently', function() {
var str = '<g><someElem someAttribute="something">hello</someElem></g>';
var $x = cheerio.load('', { xmlMode: false });
expect($x(str).html()).to.equal('<someelem someattribute="something">hello</someelem>');
});
});
});

19
node_modules/core-util-is/LICENSE generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright Node.js contributors. All rights reserved.
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.

3
node_modules/core-util-is/README.md generated vendored Normal file
View File

@ -0,0 +1,3 @@
# core-util-is
The `util.is*` functions introduced in Node v0.12.

604
node_modules/core-util-is/float.patch generated vendored Normal file
View File

@ -0,0 +1,604 @@
diff --git a/lib/util.js b/lib/util.js
index a03e874..9074e8e 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -19,430 +19,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-var formatRegExp = /%[sdj%]/g;
-exports.format = function(f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
- }
-
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function(x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s': return String(args[i++]);
- case '%d': return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
- });
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
- }
- return str;
-};
-
-
-// Mark that a method should not be used.
-// Returns a modified function which warns once by default.
-// If --no-deprecation is set, then it is a no-op.
-exports.deprecate = function(fn, msg) {
- // Allow for deprecating things in the process of starting up.
- if (isUndefined(global.process)) {
- return function() {
- return exports.deprecate(fn, msg).apply(this, arguments);
- };
- }
-
- if (process.noDeprecation === true) {
- return fn;
- }
-
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
-
- return deprecated;
-};
-
-
-var debugs = {};
-var debugEnviron;
-exports.debuglog = function(set) {
- if (isUndefined(debugEnviron))
- debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function() {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
- };
- } else {
- debugs[set] = function() {};
- }
- }
- return debugs[set];
-};
-
-
-/**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
- */
-/* legacy: obj, showHidden, depth, colors*/
-function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
- };
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
- // legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
-}
-exports.inspect = inspect;
-
-
-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
-inspect.colors = {
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [30, 39],
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
-};
-
-// Don't use 'blue' not visible on cmd.exe
-inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
-};
-
-
-function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
-
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
- '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
- return str;
- }
-}
-
-
-function stylizeNoColor(str, styleType) {
- return str;
-}
-
-
-function arrayToHash(array) {
- var hash = {};
-
- array.forEach(function(val, idx) {
- hash[val] = true;
- });
-
- return hash;
-}
-
-
-function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect &&
- value &&
- isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
- }
- return ret;
- }
-
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
-
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
-
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
-
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
- if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
- }
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- }
- if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
- }
- if (isError(value)) {
- return formatError(value);
- }
- }
-
- var base = '', array = false, braces = ['{', '}'];
-
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
-
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
-
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
- }
-
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
-
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
-
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
-
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- } else {
- return ctx.stylize('[Object]', 'special');
- }
- }
-
- ctx.seen.push(value);
-
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function(key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
- });
- }
-
- ctx.seen.pop();
-
- return reduceToSingleString(output, base, braces);
-}
-
-
-function formatPrimitive(ctx, value) {
- if (isUndefined(value))
- return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
- }
- if (isNumber(value)) {
- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0,
- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .
- if (value === 0 && 1 / value < 0)
- return ctx.stylize('-0', 'number');
- return ctx.stylize('' + value, 'number');
- }
- if (isBoolean(value))
- return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value))
- return ctx.stylize('null', 'null');
-}
-
-
-function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
-}
-
-
-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- String(i), true));
- } else {
- output.push('');
- }
- }
- keys.forEach(function(key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- key, true));
- }
- });
- return output;
-}
-
-
-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
- }
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
- }
- }
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
- }
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
- }
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n').substr(2);
- } else {
- str = '\n' + str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
- }
- }
- } else {
- str = ctx.stylize('[Circular]', 'special');
- }
- }
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
- }
- }
-
- return name + ': ' + str;
-}
-
-
-function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function(prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
-
- if (length > 60) {
- return braces[0] +
- (base === '' ? '' : base + '\n ') +
- ' ' +
- output.join(',\n ') +
- ' ' +
- braces[1];
- }
-
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
-}
-
-
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.
function isArray(ar) {
@@ -522,166 +98,10 @@ function isPrimitive(arg) {
exports.isPrimitive = isPrimitive;
function isBuffer(arg) {
- return arg instanceof Buffer;
+ return Buffer.isBuffer(arg);
}
exports.isBuffer = isBuffer;
function objectToString(o) {
return Object.prototype.toString.call(o);
-}
-
-
-function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
-}
-
-
-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
- 'Oct', 'Nov', 'Dec'];
-
-// 26 Feb 16:19:34
-function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()),
- pad(d.getMinutes()),
- pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
-}
-
-
-// log is just a thin wrapper to console.log that prepends a timestamp
-exports.log = function() {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
-};
-
-
-/**
- * Inherit the prototype methods from one constructor into another.
- *
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
- *
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
- */
-exports.inherits = function(ctor, superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
-};
-
-exports._extend = function(origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
-
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
-};
-
-function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-}
-
-
-// Deprecated old stuff.
-
-exports.p = exports.deprecate(function() {
- for (var i = 0, len = arguments.length; i < len; ++i) {
- console.error(exports.inspect(arguments[i]));
- }
-}, 'util.p: Use console.error() instead');
-
-
-exports.exec = exports.deprecate(function() {
- return require('child_process').exec.apply(this, arguments);
-}, 'util.exec is now called `child_process.exec`.');
-
-
-exports.print = exports.deprecate(function() {
- for (var i = 0, len = arguments.length; i < len; ++i) {
- process.stdout.write(String(arguments[i]));
- }
-}, 'util.print: Use console.log instead');
-
-
-exports.puts = exports.deprecate(function() {
- for (var i = 0, len = arguments.length; i < len; ++i) {
- process.stdout.write(arguments[i] + '\n');
- }
-}, 'util.puts: Use console.log instead');
-
-
-exports.debug = exports.deprecate(function(x) {
- process.stderr.write('DEBUG: ' + x + '\n');
-}, 'util.debug: Use console.error instead');
-
-
-exports.error = exports.deprecate(function(x) {
- for (var i = 0, len = arguments.length; i < len; ++i) {
- process.stderr.write(arguments[i] + '\n');
- }
-}, 'util.error: Use console.error instead');
-
-
-exports.pump = exports.deprecate(function(readStream, writeStream, callback) {
- var callbackCalled = false;
-
- function call(a, b, c) {
- if (callback && !callbackCalled) {
- callback(a, b, c);
- callbackCalled = true;
- }
- }
-
- readStream.addListener('data', function(chunk) {
- if (writeStream.write(chunk) === false) readStream.pause();
- });
-
- writeStream.addListener('drain', function() {
- readStream.resume();
- });
-
- readStream.addListener('end', function() {
- writeStream.end();
- });
-
- readStream.addListener('close', function() {
- call();
- });
-
- readStream.addListener('error', function(err) {
- writeStream.end();
- call(err);
- });
-
- writeStream.addListener('error', function(err) {
- readStream.destroy();
- call(err);
- });
-}, 'util.pump(): Use readableStream.pipe() instead');
-
-
-var uv;
-exports._errnoException = function(err, syscall) {
- if (isUndefined(uv)) uv = process.binding('uv');
- var errname = uv.errname(err);
- var e = new Error(syscall + ' ' + errname);
- e.code = errname;
- e.errno = errname;
- e.syscall = syscall;
- return e;
-};
+}

107
node_modules/core-util-is/lib/util.js generated vendored Normal file
View File

@ -0,0 +1,107 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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.
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.
function isArray(arg) {
if (Array.isArray) {
return Array.isArray(arg);
}
return objectToString(arg) === '[object Array]';
}
exports.isArray = isArray;
function isBoolean(arg) {
return typeof arg === 'boolean';
}
exports.isBoolean = isBoolean;
function isNull(arg) {
return arg === null;
}
exports.isNull = isNull;
function isNullOrUndefined(arg) {
return arg == null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function isNumber(arg) {
return typeof arg === 'number';
}
exports.isNumber = isNumber;
function isString(arg) {
return typeof arg === 'string';
}
exports.isString = isString;
function isSymbol(arg) {
return typeof arg === 'symbol';
}
exports.isSymbol = isSymbol;
function isUndefined(arg) {
return arg === void 0;
}
exports.isUndefined = isUndefined;
function isRegExp(re) {
return objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
exports.isObject = isObject;
function isDate(d) {
return objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function isError(e) {
return (objectToString(e) === '[object Error]' || e instanceof Error);
}
exports.isError = isError;
function isFunction(arg) {
return typeof arg === 'function';
}
exports.isFunction = isFunction;
function isPrimitive(arg) {
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
}
exports.isPrimitive = isPrimitive;
exports.isBuffer = Buffer.isBuffer;
function objectToString(o) {
return Object.prototype.toString.call(o);
}

86
node_modules/core-util-is/package.json generated vendored Normal file
View File

@ -0,0 +1,86 @@
{
"_args": [
[
"core-util-is@~1.0.0",
"/Users/okennedy/Documents/Website/node_modules/readable-stream"
]
],
"_from": "core-util-is@>=1.0.0 <1.1.0",
"_id": "core-util-is@1.0.2",
"_inCache": true,
"_installable": true,
"_location": "/core-util-is",
"_nodeVersion": "4.0.0",
"_npmUser": {
"email": "i@izs.me",
"name": "isaacs"
},
"_npmVersion": "3.3.2",
"_phantomChildren": {},
"_requested": {
"name": "core-util-is",
"raw": "core-util-is@~1.0.0",
"rawSpec": "~1.0.0",
"scope": null,
"spec": ">=1.0.0 <1.1.0",
"type": "range"
},
"_requiredBy": [
"/readable-stream"
],
"_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7",
"_shrinkwrap": null,
"_spec": "core-util-is@~1.0.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/readable-stream",
"author": {
"email": "i@izs.me",
"name": "Isaac Z. Schlueter",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/isaacs/core-util-is/issues"
},
"dependencies": {},
"description": "The `util.is*` functions introduced in Node v0.12.",
"devDependencies": {
"tap": "^2.3.0"
},
"directories": {},
"dist": {
"shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7",
"tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
},
"gitHead": "a177da234df5638b363ddc15fa324619a38577c8",
"homepage": "https://github.com/isaacs/core-util-is#readme",
"keywords": [
"isArray",
"isBuffer",
"isNumber",
"isRegExp",
"isString",
"isThat",
"isThis",
"polyfill",
"util"
],
"license": "MIT",
"main": "lib/util.js",
"maintainers": [
{
"name": "isaacs",
"email": "i@izs.me"
}
],
"name": "core-util-is",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/core-util-is.git"
},
"scripts": {
"test": "tap test.js"
},
"version": "1.0.2"
}

68
node_modules/core-util-is/test.js generated vendored Normal file
View File

@ -0,0 +1,68 @@
var assert = require('tap');
var t = require('./lib/util');
assert.equal(t.isArray([]), true);
assert.equal(t.isArray({}), false);
assert.equal(t.isBoolean(null), false);
assert.equal(t.isBoolean(true), true);
assert.equal(t.isBoolean(false), true);
assert.equal(t.isNull(null), true);
assert.equal(t.isNull(undefined), false);
assert.equal(t.isNull(false), false);
assert.equal(t.isNull(), false);
assert.equal(t.isNullOrUndefined(null), true);
assert.equal(t.isNullOrUndefined(undefined), true);
assert.equal(t.isNullOrUndefined(false), false);
assert.equal(t.isNullOrUndefined(), true);
assert.equal(t.isNumber(null), false);
assert.equal(t.isNumber('1'), false);
assert.equal(t.isNumber(1), true);
assert.equal(t.isString(null), false);
assert.equal(t.isString('1'), true);
assert.equal(t.isString(1), false);
assert.equal(t.isSymbol(null), false);
assert.equal(t.isSymbol('1'), false);
assert.equal(t.isSymbol(1), false);
assert.equal(t.isSymbol(Symbol()), true);
assert.equal(t.isUndefined(null), false);
assert.equal(t.isUndefined(undefined), true);
assert.equal(t.isUndefined(false), false);
assert.equal(t.isUndefined(), true);
assert.equal(t.isRegExp(null), false);
assert.equal(t.isRegExp('1'), false);
assert.equal(t.isRegExp(new RegExp()), true);
assert.equal(t.isObject({}), true);
assert.equal(t.isObject([]), true);
assert.equal(t.isObject(new RegExp()), true);
assert.equal(t.isObject(new Date()), true);
assert.equal(t.isDate(null), false);
assert.equal(t.isDate('1'), false);
assert.equal(t.isDate(new Date()), true);
assert.equal(t.isError(null), false);
assert.equal(t.isError({ err: true }), false);
assert.equal(t.isError(new Error()), true);
assert.equal(t.isFunction(null), false);
assert.equal(t.isFunction({ }), false);
assert.equal(t.isFunction(function() {}), true);
assert.equal(t.isPrimitive(null), true);
assert.equal(t.isPrimitive(''), true);
assert.equal(t.isPrimitive(0), true);
assert.equal(t.isPrimitive(new Date()), false);
assert.equal(t.isBuffer(null), false);
assert.equal(t.isBuffer({}), false);
assert.equal(t.isBuffer(new Buffer(0)), true);

11
node_modules/css-select/LICENSE generated vendored Normal file
View File

@ -0,0 +1,11 @@
Copyright (c) Felix Böhm
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

128
node_modules/css-select/README.md generated vendored Normal file
View File

@ -0,0 +1,128 @@
# css-select [![NPM version](http://img.shields.io/npm/v/css-select.svg)](https://npmjs.org/package/css-select) [![Build Status](https://travis-ci.org/fb55/htmlparser2.svg)](http://travis-ci.org/fb55/css-select) [![Downloads](https://img.shields.io/npm/dm/css-select.svg)](https://npmjs.org/package/css-select) [![Coverage](https://coveralls.io/repos/fb55/css-select/badge.svg?branch=master)](https://coveralls.io/r/fb55/css-select)
a CSS selector compiler/engine
## What?
css-select turns CSS selectors into functions that tests if elements match them. When searching for elements, testing is executed "from the top", similar to how browsers execute CSS selectors.
In its default configuration, css-select queries the DOM structure of the [`domhandler`](https://github.com/fb55/domhandler) module (also known as htmlparser2 DOM).
__Features:__
- Full implementation of CSS3 selectors
- Partial implementation of jQuery/Sizzle extensions
- Very high test coverage
- Pretty good performance
## Why?
The traditional approach of executing CSS selectors, named left-to-right execution, is to execute every component of the selector in order, from left to right _(duh)_. The execution of the selector `a b` for example will first query for `a` elements, then search these for `b` elements. (That's the approach of eg. [`Sizzle`](https://github.com/jquery/sizzle), [`nwmatcher`](https://github.com/dperini/nwmatcher/) and [`qwery`](https://github.com/ded/qwery).)
While this works, it has some downsides: Children of `a`s will be checked multiple times; first, to check if they are also `a`s, then, for every superior `a` once, if they are `b`s. Using [Big O notation](http://en.wikipedia.org/wiki/Big_O_notation), that would be `O(n^k)`, where `k` is the number of descendant selectors (that's the space in the example above).
The far more efficient approach is to first look for `b` elements, then check if they have superior `a` elements: Using big O notation again, that would be `O(n)`. That's called right-to-left execution.
And that's what css-select does and why it's quite performant.
## How does it work?
By building a stack of functions.
_Wait, what?_
Okay, so let's suppose we want to compile the selector `a b` again, for right-to-left execution. We start by _parsing_ the selector, which means we turn the selector into an array of the building-blocks of the selector, so we can distinguish them easily. That's what the [`css-what`](https://github.com/fb55/css-what) module is for, if you want to have a look.
Anyway, after parsing, we end up with an array like this one:
```js
[
{ type: 'tag', name: 'a' },
{ type: 'descendant' },
{ type: 'tag', name: 'b' }
]
```
Actually, this array is wrapped in another array, but that's another story (involving commas in selectors).
Now that we know the meaning of every part of the selector, we can compile it. That's where it becomes interesting.
The basic idea is to turn every part of the selector into a function, which takes an element as its only argument. The function checks whether a passed element matches its part of the selector: If it does, the element is passed to the next turned-into-a-function part of the selector, which does the same. If an element is accepted by all parts of the selector, it _matches_ the selector and double rainbow ALL THE WAY.
As said before, we want to do right-to-left execution with all the big O improvements nonsense, so elements are passed from the rightmost part of the selector (`b` in our example) to the leftmost (~~which would be `c`~~ of course `a`).
_//TODO: More in-depth description. Implementation details. Build a spaceship._
## API
```js
var CSSselect = require("css-select");
```
#### `CSSselect(query, elems, options)`
Queries `elems`, returns an array containing all matches.
- `query` can be either a CSS selector or a function.
- `elems` can be either an array of elements, or a single element. If it is an element, its children will be queried.
- `options` is described below.
Aliases: `CSSselect.selectAll(query, elems)`, `CSSselect.iterate(query, elems)`.
#### `CSSselect.compile(query)`
Compiles the query, returns a function.
#### `CSSselect.is(elem, query, options)`
Tests whether or not an element is matched by `query`. `query` can be either a CSS selector or a function.
#### `CSSselect.selectOne(query, elems, options)`
Arguments are the same as for `CSSselect(query, elems)`. Only returns the first match, or `null` if there was no match.
### Options
- `xmlMode`: When enabled, tag names will be case-sensitive. Default: `false`.
- `strict`: Limits the module to only use CSS3 selectors. Default: `false`.
- `rootFunc`: The last function in the stack, will be called with the last element that's looked at. Should return `true`.
## Supported selectors:
* Universal (`*`)
* Tag (`<tagname>`)
* Descendant (` `)
* Child (`>`)
* Parent (`<`) *
* Sibling (`+`)
* Adjacent (`~`)
* Attribute (`[attr=foo]`), with supported comparisons:
* `[attr]` (existential)
* `=`
* `~=`
* `|=`
* `*=`
* `^=`
* `$=`
* `!=` *
* Also, `i` can be added after the comparison to make the comparison case-insensitive (eg. `[attr=foo i]`) *
* Pseudos:
* `:not`
* `:contains` *
* `:has` *
* `:root`
* `:empty`
* `:parent` *
* `:[first|last]-child[-of-type]`
* `:only-of-type`, `:only-child`
* `:nth-[last-]child[-of-type]`
* `:selected` *, `:checked`
* `:enabled`, `:disabled`
* `:header`, `:button`, `:input`, `:text`, `:checkbox`, `:file`, `:password`, `:reset`, `:radio` etc. *
* `:matches` *
__*__: Not part of CSS3
---
License: BSD-like

57
node_modules/css-select/index.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
"use strict";
module.exports = CSSselect;
var Pseudos = require("./lib/pseudos.js"),
DomUtils = require("domutils"),
findOne = DomUtils.findOne,
findAll = DomUtils.findAll,
getChildren = DomUtils.getChildren,
removeSubsets = DomUtils.removeSubsets,
falseFunc = require("boolbase").falseFunc,
compile = require("./lib/compile.js"),
compileUnsafe = compile.compileUnsafe;
function getSelectorFunc(searchFunc){
return function select(query, elems, options){
if(typeof query !== "function") query = compileUnsafe(query, options);
if(!Array.isArray(elems)) elems = getChildren(elems);
else elems = removeSubsets(elems);
return searchFunc(query, elems);
};
}
var selectAll = getSelectorFunc(function selectAll(query, elems){
return (query === falseFunc || !elems || elems.length === 0) ? [] : findAll(query, elems);
});
var selectOne = getSelectorFunc(function selectOne(query, elems){
return (query === falseFunc || !elems || elems.length === 0) ? null : findOne(query, elems);
});
function is(elem, query, options){
return (typeof query === "function" ? query : compile(query, options))(elem);
}
/*
the exported interface
*/
function CSSselect(query, elems, options){
return selectAll(query, elems, options);
}
CSSselect.compile = compile;
CSSselect.filters = Pseudos.filters;
CSSselect.pseudos = Pseudos.pseudos;
CSSselect.selectAll = selectAll;
CSSselect.selectOne = selectOne;
CSSselect.is = is;
//legacy methods (might be removed)
CSSselect.parse = compile;
CSSselect.iterate = selectAll;
//useful for debugging
CSSselect._compileUnsafe = compileUnsafe;

181
node_modules/css-select/lib/attributes.js generated vendored Normal file
View File

@ -0,0 +1,181 @@
var DomUtils = require("domutils"),
hasAttrib = DomUtils.hasAttrib,
getAttributeValue = DomUtils.getAttributeValue,
falseFunc = require("boolbase").falseFunc;
//https://github.com/slevithan/XRegExp/blob/master/src/xregexp.js#L469
var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g;
/*
attribute selectors
*/
var attributeRules = {
__proto__: null,
equals: function(next, data){
var name = data.name,
value = data.value;
if(data.ignoreCase){
value = value.toLowerCase();
return function equalsIC(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.toLowerCase() === value && next(elem);
};
}
return function equals(elem){
return getAttributeValue(elem, name) === value && next(elem);
};
},
hyphen: function(next, data){
var name = data.name,
value = data.value,
len = value.length;
if(data.ignoreCase){
value = value.toLowerCase();
return function hyphenIC(elem){
var attr = getAttributeValue(elem, name);
return attr != null &&
(attr.length === len || attr.charAt(len) === "-") &&
attr.substr(0, len).toLowerCase() === value &&
next(elem);
};
}
return function hyphen(elem){
var attr = getAttributeValue(elem, name);
return attr != null &&
attr.substr(0, len) === value &&
(attr.length === len || attr.charAt(len) === "-") &&
next(elem);
};
},
element: function(next, data){
var name = data.name,
value = data.value;
if(/\s/.test(value)){
return falseFunc;
}
value = value.replace(reChars, "\\$&");
var pattern = "(?:^|\\s)" + value + "(?:$|\\s)",
flags = data.ignoreCase ? "i" : "",
regex = new RegExp(pattern, flags);
return function element(elem){
var attr = getAttributeValue(elem, name);
return attr != null && regex.test(attr) && next(elem);
};
},
exists: function(next, data){
var name = data.name;
return function exists(elem){
return hasAttrib(elem, name) && next(elem);
};
},
start: function(next, data){
var name = data.name,
value = data.value,
len = value.length;
if(len === 0){
return falseFunc;
}
if(data.ignoreCase){
value = value.toLowerCase();
return function startIC(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.substr(0, len).toLowerCase() === value && next(elem);
};
}
return function start(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.substr(0, len) === value && next(elem);
};
},
end: function(next, data){
var name = data.name,
value = data.value,
len = -value.length;
if(len === 0){
return falseFunc;
}
if(data.ignoreCase){
value = value.toLowerCase();
return function endIC(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.substr(len).toLowerCase() === value && next(elem);
};
}
return function end(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.substr(len) === value && next(elem);
};
},
any: function(next, data){
var name = data.name,
value = data.value;
if(value === ""){
return falseFunc;
}
if(data.ignoreCase){
var regex = new RegExp(value.replace(reChars, "\\$&"), "i");
return function anyIC(elem){
var attr = getAttributeValue(elem, name);
return attr != null && regex.test(attr) && next(elem);
};
}
return function any(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.indexOf(value) >= 0 && next(elem);
};
},
not: function(next, data){
var name = data.name,
value = data.value;
if(value === ""){
return function notEmpty(elem){
return !!getAttributeValue(elem, name) && next(elem);
};
} else if(data.ignoreCase){
value = value.toLowerCase();
return function notIC(elem){
var attr = getAttributeValue(elem, name);
return attr != null && attr.toLowerCase() !== value && next(elem);
};
}
return function not(elem){
return getAttributeValue(elem, name) !== value && next(elem);
};
}
};
module.exports = {
compile: function(next, data, options){
if(options && options.strict && (
data.ignoreCase || data.action === "not"
)) throw SyntaxError("Unsupported attribute selector");
return attributeRules[data.action](next, data);
},
rules: attributeRules
};

181
node_modules/css-select/lib/compile.js generated vendored Normal file
View File

@ -0,0 +1,181 @@
/*
compiles a selector to an executable function
*/
module.exports = compile;
module.exports.compileUnsafe = compileUnsafe;
var parse = require("css-what"),
DomUtils = require("domutils"),
isTag = DomUtils.isTag,
Rules = require("./general.js"),
sortRules = require("./sort.js"),
BaseFuncs = require("boolbase"),
trueFunc = BaseFuncs.trueFunc,
falseFunc = BaseFuncs.falseFunc,
procedure = require("./procedure.json");
function compile(selector, options){
var next = compileUnsafe(selector, options);
return wrap(next);
}
function wrap(next){
return function base(elem){
return isTag(elem) && next(elem);
};
}
function compileUnsafe(selector, options){
var token = parse(selector, options);
return compileToken(token, options);
}
function compileToken(token, options){
token.forEach(sortRules);
if(options && options.context){
var ctx = options.context;
token.forEach(function(t){
if(!isTraversal(t[0])){
t.unshift({type: "descendant"});
}
});
var context = Array.isArray(ctx) ?
function(elem){
return ctx.indexOf(elem) >= 0;
} : function(elem){
return ctx === elem;
};
if(options.rootFunc){
var root = options.rootFunc;
options.rootFunc = function(elem){
return context(elem) && root(elem);
};
} else {
options.rootFunc = context;
}
}
return token
.map(compileRules, options)
.reduce(reduceRules, falseFunc);
}
function isTraversal(t){
return procedure[t.type] < 0;
}
function compileRules(rules){
if(rules.length === 0) return falseFunc;
var options = this;
return rules.reduce(function(func, rule){
if(func === falseFunc) return func;
return Rules[rule.type](func, rule, options);
}, options && options.rootFunc || trueFunc);
}
function reduceRules(a, b){
if(b === falseFunc || a === trueFunc){
return a;
}
if(a === falseFunc || b === trueFunc){
return b;
}
return function combine(elem){
return a(elem) || b(elem);
};
}
//:not, :has and :matches have to compile selectors
//doing this in lib/pseudos.js would lead to circular dependencies,
//so we add them here
var Pseudos = require("./pseudos.js"),
filters = Pseudos.filters,
existsOne = DomUtils.existsOne,
isTag = DomUtils.isTag,
getChildren = DomUtils.getChildren;
function containsTraversal(t){
return t.some(isTraversal);
}
function stripQuotes(str){
var firstChar = str.charAt(0);
if(firstChar === str.slice(-1) && (firstChar === "'" || firstChar === "\"")){
str = str.slice(1, -1);
}
return str;
}
filters.not = function(next, select, options){
var func,
opts = {
xmlMode: !!(options && options.xmlMode),
strict: !!(options && options.strict)
};
select = stripQuotes(select);
if(opts.strict){
var tokens = parse(select);
if(tokens.length > 1 || tokens.some(containsTraversal)){
throw new SyntaxError("complex selectors in :not aren't allowed in strict mode");
}
func = compileToken(tokens, opts);
} else {
func = compileUnsafe(select, opts);
}
if(func === falseFunc) return next;
if(func === trueFunc) return falseFunc;
return function(elem){
return !func(elem) && next(elem);
};
};
filters.has = function(next, selector, options){
//TODO add a dynamic context in front of every selector with a traversal
//:has will never be reached with options.strict == true
var opts = {
xmlMode: !!(options && options.xmlMode),
strict: !!(options && options.strict)
};
var func = compileUnsafe(selector, opts);
if(func === falseFunc) return falseFunc;
if(func === trueFunc) return function(elem){
return getChildren(elem).some(isTag) && next(elem);
};
func = wrap(func);
return function has(elem){
return next(elem) && existsOne(func, getChildren(elem));
};
};
filters.matches = function(next, selector, options){
var opts = {
xmlMode: !!(options && options.xmlMode),
strict: !!(options && options.strict),
rootFunc: next
};
selector = stripQuotes(selector);
return compileUnsafe(selector, opts);
};

86
node_modules/css-select/lib/general.js generated vendored Normal file
View File

@ -0,0 +1,86 @@
var DomUtils = require("domutils"),
isTag = DomUtils.isTag,
getParent = DomUtils.getParent,
getChildren = DomUtils.getChildren,
getSiblings = DomUtils.getSiblings,
getName = DomUtils.getName;
/*
all available rules
*/
module.exports = {
__proto__: null,
attribute: require("./attributes.js").compile,
pseudo: require("./pseudos.js").compile,
//tags
tag: function(next, data){
var name = data.name;
return function tag(elem){
return getName(elem) === name && next(elem);
};
},
//traversal
descendant: function(next){
return function descendant(elem){
var found = false;
while(!found && (elem = getParent(elem))){
found = next(elem);
}
return found;
};
},
parent: function(next, data, options){
if(options && options.strict) throw SyntaxError("Parent selector isn't part of CSS3");
return function parent(elem){
return getChildren(elem).some(test);
};
function test(elem){
return isTag(elem) && next(elem);
}
},
child: function(next){
return function child(elem){
var parent = getParent(elem);
return !!parent && next(parent);
};
},
sibling: function(next){
return function sibling(elem){
var siblings = getSiblings(elem);
for(var i = 0; i < siblings.length; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem) break;
if(next(siblings[i])) return true;
}
}
return false;
};
},
adjacent: function(next){
return function adjacent(elem){
var siblings = getSiblings(elem),
lastElement;
for(var i = 0; i < siblings.length; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem) break;
lastElement = siblings[i];
}
}
return !!lastElement && next(lastElement);
};
},
universal: function(next){
return next;
}
};

11
node_modules/css-select/lib/procedure.json generated vendored Normal file
View File

@ -0,0 +1,11 @@
{
"universal": 5,
"tag": 3,
"attribute": 1,
"pseudo": 0,
"descendant": -1,
"child": -1,
"parent": -1,
"sibling": -1,
"adjacent": -1
}

342
node_modules/css-select/lib/pseudos.js generated vendored Normal file
View File

@ -0,0 +1,342 @@
/*
pseudo selectors
---
they are available in two forms:
* filters called when the selector
is compiled and return a function
that needs to return next()
* pseudos get called on execution
they need to return a boolean
*/
var DomUtils = require("domutils"),
isTag = DomUtils.isTag,
getText = DomUtils.getText,
getParent = DomUtils.getParent,
getChildren = DomUtils.getChildren,
getSiblings = DomUtils.getSiblings,
hasAttrib = DomUtils.hasAttrib,
getName = DomUtils.getName,
getAttribute= DomUtils.getAttributeValue,
getNCheck = require("nth-check"),
checkAttrib = require("./attributes.js").rules.equals,
BaseFuncs = require("boolbase"),
trueFunc = BaseFuncs.trueFunc,
falseFunc = BaseFuncs.falseFunc;
//helper methods
function getFirstElement(elems){
for(var i = 0; elems && i < elems.length; i++){
if(isTag(elems[i])) return elems[i];
}
}
function getAttribFunc(name, value){
var data = {name: name, value: value};
return function attribFunc(next){
return checkAttrib(next, data);
};
}
function getChildFunc(next){
return function(elem){
return !!getParent(elem) && next(elem);
};
}
var filters = {
contains: function(next, text){
if(
(text.charAt(0) === "\"" || text.charAt(0) === "'") &&
text.charAt(0) === text.substr(-1)
){
text = text.slice(1, -1);
}
return function contains(elem){
return next(elem) && getText(elem).indexOf(text) >= 0;
};
},
//location specific methods
"nth-child": function(next, rule){
var func = getNCheck(rule);
if(func === falseFunc) return func;
if(func === trueFunc) return getChildFunc(next);
return function nthChild(elem){
var siblings = getSiblings(elem);
for(var i = 0, pos = 0; i < siblings.length; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem) break;
else pos++;
}
}
return func(pos) && next(elem);
};
},
"nth-last-child": function(next, rule){
var func = getNCheck(rule);
if(func === falseFunc) return func;
if(func === trueFunc) return getChildFunc(next);
return function nthLastChild(elem){
var siblings = getSiblings(elem);
for(var pos = 0, i = siblings.length - 1; i >= 0; i--){
if(isTag(siblings[i])){
if(siblings[i] === elem) break;
else pos++;
}
}
return func(pos) && next(elem);
};
},
"nth-of-type": function(next, rule){
var func = getNCheck(rule);
if(func === falseFunc) return func;
if(func === trueFunc) return getChildFunc(next);
return function nthOfType(elem){
var siblings = getSiblings(elem);
for(var pos = 0, i = 0; i < siblings.length; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem) break;
if(getName(siblings[i]) === getName(elem)) pos++;
}
}
return func(pos) && next(elem);
};
},
"nth-last-of-type": function(next, rule){
var func = getNCheck(rule);
if(func === falseFunc) return func;
if(func === trueFunc) return getChildFunc(next);
return function nthLastOfType(elem){
var siblings = getSiblings(elem);
for(var pos = 0, i = siblings.length - 1; i >= 0; i--){
if(isTag(siblings[i])){
if(siblings[i] === elem) break;
if(getName(siblings[i]) === getName(elem)) pos++;
}
}
return func(pos) && next(elem);
};
},
//jQuery extensions (others follow as pseudos)
checkbox: getAttribFunc("type", "checkbox"),
file: getAttribFunc("type", "file"),
password: getAttribFunc("type", "password"),
radio: getAttribFunc("type", "radio"),
reset: getAttribFunc("type", "reset"),
image: getAttribFunc("type", "image"),
submit: getAttribFunc("type", "submit")
};
//while filters are precompiled, pseudos get called when they are needed
var pseudos = {
root: function(elem){
return !getParent(elem);
},
empty: function(elem){
return !getChildren(elem).some(function(elem){
return isTag(elem) || elem.type === "text";
});
},
"first-child": function(elem){
return getFirstElement(getSiblings(elem)) === elem;
},
"last-child": function(elem){
var siblings = getSiblings(elem);
for(var i = siblings.length - 1; i >= 0; i--){
if(siblings[i] === elem) return true;
if(isTag(siblings[i])) break;
}
return false;
},
"first-of-type": function(elem){
var siblings = getSiblings(elem);
for(var i = 0; i < siblings.length; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem) return true;
if(getName(siblings[i]) === getName(elem)) break;
}
}
return false;
},
"last-of-type": function(elem){
var siblings = getSiblings(elem);
for(var i = siblings.length-1; i >= 0; i--){
if(isTag(siblings[i])){
if(siblings[i] === elem) return true;
if(getName(siblings[i]) === getName(elem)) break;
}
}
return false;
},
"only-of-type": function(elem){
var siblings = getSiblings(elem);
for(var i = 0, j = siblings.length; i < j; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem) continue;
if(getName(siblings[i]) === getName(elem)) return false;
}
}
return true;
},
"only-child": function(elem){
var siblings = getSiblings(elem);
for(var i = 0; i < siblings.length; i++){
if(isTag(siblings[i]) && siblings[i] !== elem) return false;
}
return true;
},
//forms
//to consider: :target, :enabled
selected: function(elem){
if(hasAttrib(elem, "selected")) return true;
else if(getName(elem) !== "option") return false;
//the first <option> in a <select> is also selected
var parent = getParent(elem);
if(
!parent ||
getName(parent) !== "select" ||
hasAttrib(parent, "multiple")
) return false;
var siblings = getChildren(parent),
sawElem = false;
for(var i = 0; i < siblings.length; i++){
if(isTag(siblings[i])){
if(siblings[i] === elem){
sawElem = true;
} else if(!sawElem){
return false;
} else if(hasAttrib(siblings[i], "selected")){
return false;
}
}
}
return sawElem;
},
disabled: function(elem){
return hasAttrib(elem, "disabled");
},
enabled: function(elem){
return !hasAttrib(elem, "disabled");
},
checked: function(elem){
return hasAttrib(elem, "checked") || pseudos.selected(elem);
},
//jQuery extensions
//:parent is the inverse of :empty
parent: function(elem){
return !pseudos.empty(elem);
},
header: function(elem){
var name = getName(elem);
return name === "h1" ||
name === "h2" ||
name === "h3" ||
name === "h4" ||
name === "h5" ||
name === "h6";
},
button: function(elem){
var name = getName(elem);
return name === "button" ||
name === "input" &&
getAttribute(elem, "type") === "button";
},
input: function(elem){
var name = getName(elem);
return name === "input" ||
name === "textarea" ||
name === "select" ||
name === "button";
},
text: function(elem){
var attr;
return getName(elem) === "input" && (
!(attr = getAttribute(elem, "type")) ||
attr.toLowerCase() === "text"
);
}
};
function verifyArgs(func, name, subselect){
if(subselect === null){
if(func.length > 1){
throw new SyntaxError("pseudo-selector :" + name + " requires an argument");
}
} else {
if(func.length === 1){
throw new SyntaxError("pseudo-selector :" + name + " doesn't have any arguments");
}
}
}
//TODO this feels hacky
var re_CSS3 = /^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/;
module.exports = {
compile: function(next, data, options){
var name = data.name,
subselect = data.data;
if(options && options.strict && !re_CSS3.test(name)){
throw SyntaxError(":" + name + " isn't part of CSS3");
}
if(typeof filters[name] === "function"){
verifyArgs(filters[name], name, subselect);
return filters[name](next, subselect, options);
} else if(typeof pseudos[name] === "function"){
var func = pseudos[name];
verifyArgs(func, name, subselect);
if(next === trueFunc) return func;
return function pseudoArgs(elem){
return func(elem, subselect) && next(elem);
};
} else {
throw new SyntaxError("unmatched pseudo-class :" + name);
}
},
filters: filters,
pseudos: pseudos
};

45
node_modules/css-select/lib/sort.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
module.exports = sortByProcedure;
/*
sort the parts of the passed selector,
as there is potential for optimization
(some types of selectors are faster than others)
*/
var procedure = require("./procedure.json");
var ATTRIBUTE = procedure.attribute;
var attributes = {
__proto__: null,
exists: 8,
equals: 7,
not: 6,
start: 5,
end: 4,
any: 3,
hyphen: 2,
element: 1
};
function sortByProcedure(arr){
for(var i = 1; i < arr.length; i++){
var procNew = procedure[arr[i].type];
if(procNew < 0) continue;
for(var j = i - 1; j >= 0; j--){
if(
procNew > procedure[arr[j].type] || !(
procNew === ATTRIBUTE &&
procedure[arr[j].type] === ATTRIBUTE &&
attributes[arr[i].action] <= attributes[arr[j].action]
)
) break;
var tmp = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = tmp;
}
}
}

116
node_modules/css-select/package.json generated vendored Normal file
View File

@ -0,0 +1,116 @@
{
"_args": [
[
"css-select@~1.0.0",
"/Users/okennedy/Documents/Website/node_modules/cheerio"
]
],
"_from": "css-select@>=1.0.0 <1.1.0",
"_id": "css-select@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/css-select",
"_nodeVersion": "1.0.4",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "2.4.1",
"_phantomChildren": {},
"_requested": {
"name": "css-select",
"raw": "css-select@~1.0.0",
"rawSpec": "~1.0.0",
"scope": null,
"spec": ">=1.0.0 <1.1.0",
"type": "range"
},
"_requiredBy": [
"/cheerio"
],
"_resolved": "https://registry.npmjs.org/css-select/-/css-select-1.0.0.tgz",
"_shasum": "b1121ca51848dd264e2244d058cee254deeb44b0",
"_shrinkwrap": null,
"_spec": "css-select@~1.0.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/cheerio",
"author": {
"email": "me@feedic.com",
"name": "Felix Boehm"
},
"bugs": {
"url": "https://github.com/fb55/css-select/issues"
},
"dependencies": {
"boolbase": "~1.0.0",
"css-what": "1.0",
"domutils": "1.4",
"nth-check": "~1.0.0"
},
"description": "a CSS selector compiler/engine",
"devDependencies": {
"cheerio-soupselect": "*",
"coveralls": "*",
"expect.js": "*",
"htmlparser2": "*",
"istanbul": "*",
"jshint": "2",
"mocha": "*",
"mocha-lcov-reporter": "*"
},
"directories": {},
"dist": {
"shasum": "b1121ca51848dd264e2244d058cee254deeb44b0",
"tarball": "http://registry.npmjs.org/css-select/-/css-select-1.0.0.tgz"
},
"files": [
"index.js",
"lib"
],
"gitHead": "c73512d9b5b4dc3f537702283143c9463b4f7d7d",
"homepage": "https://github.com/fb55/css-select",
"jshintConfig": {
"eqeqeq": true,
"eqnull": true,
"freeze": true,
"globals": {
"describe": true,
"it": true
},
"latedef": "nofunc",
"noarg": true,
"node": true,
"nonbsp": true,
"proto": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
"unused": true
},
"keywords": [
"css",
"selector",
"sizzle"
],
"license": "BSD-like",
"maintainers": [
{
"name": "feedic",
"email": "me@feedic.com"
}
],
"name": "css-select",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/fb55/css-select.git"
},
"scripts": {
"coveralls": "npm run lint && npm run lcov && (cat coverage/lcov.info | coveralls || exit 0)",
"lcov": "istanbul cover _mocha --report lcovonly -- -R spec",
"lint": "jshint index.js lib/*.js test/*.js",
"test": "mocha && npm run lint"
},
"version": "1.0.0"
}

11
node_modules/css-what/LICENSE generated vendored Normal file
View File

@ -0,0 +1,11 @@
Copyright (c) Felix Böhm
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

182
node_modules/css-what/index.js generated vendored Normal file
View File

@ -0,0 +1,182 @@
"use strict";
module.exports = parse;
var re_ws = /^\s/,
re_name = /^(?:\\.|[\w\-\u00c0-\uFFFF])+/,
re_escape = /\\([\da-f]{1,6}\s?|(\s)|.)/ig,
//modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87
re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])(.*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;
var actionTypes = {
__proto__: null,
"undefined": "exists",
"": "equals",
"~": "element",
"^": "start",
"$": "end",
"*": "any",
"!": "not",
"|": "hyphen"
};
var simpleSelectors = {
__proto__: null,
">": "child",
"<": "parent",
"~": "sibling",
"+": "adjacent"
};
var attribSelectors = {
__proto__: null,
"#": ["id", "equals"],
".": ["class", "element"]
};
//unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L139
function funescape( _, escaped, escapedWhitespace ) {
var high = "0x" + escaped - 0x10000;
// NaN means non-codepoint
// Support: Firefox
// Workaround erroneous numeric interpretation of +"0x"
return high !== high || escapedWhitespace ?
escaped :
// BMP codepoint
high < 0 ?
String.fromCharCode( high + 0x10000 ) :
// Supplemental Plane codepoint (surrogate pair)
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
}
function unescapeCSS(str){
return str.replace(re_escape, funescape);
}
function getClosingPos(selector){
var pos = 1, counter = 1, len = selector.length;
for(; counter > 0 && pos < len; pos++){
if(selector.charAt(pos) === "(") counter++;
else if(selector.charAt(pos) === ")") counter--;
}
return pos;
}
function parse(selector, options){
selector = (selector + "").trimLeft();
var subselects = [],
tokens = [],
sawWS = false,
data, firstChar, name;
function getName(){
var sub = selector.match(re_name)[0];
selector = selector.substr(sub.length);
return unescapeCSS(sub);
}
while(selector !== ""){
if(re_name.test(selector)){
if(sawWS){
tokens.push({type: "descendant"});
sawWS = false;
}
name = getName();
if(!options || ("lowerCaseTags" in options ? options.lowerCaseTags : !options.xmlMode)){
name = name.toLowerCase();
}
tokens.push({type: "tag", name: name});
} else if(re_ws.test(selector)){
sawWS = true;
selector = selector.trimLeft();
} else {
firstChar = selector.charAt(0);
selector = selector.substr(1);
if(firstChar in simpleSelectors){
tokens.push({type: simpleSelectors[firstChar]});
selector = selector.trimLeft();
sawWS = false;
continue;
} else if(firstChar === ","){
if(tokens.length === 0){
throw new SyntaxError("empty sub-selector");
}
subselects.push(tokens);
tokens = [];
selector = selector.trimLeft();
sawWS = false;
continue;
} else if(sawWS){
tokens.push({type: "descendant"});
sawWS = false;
}
if(firstChar === "*"){
tokens.push({type: "universal"});
} else if(firstChar in attribSelectors){
tokens.push({
type: "attribute",
name: attribSelectors[firstChar][0],
action: attribSelectors[firstChar][1],
value: getName(),
ignoreCase: false
});
} else if(firstChar === "["){
data = selector.match(re_attr);
if(!data){
throw new SyntaxError("Malformed attribute selector: " + selector);
}
selector = selector.substr(data[0].length);
name = unescapeCSS(data[1]);
if(
!options || (
"lowerCaseAttributeNames" in options ?
options.lowerCaseAttributeNames :
!options.xmlMode
)
){
name = name.toLowerCase();
}
tokens.push({
type: "attribute",
name: name,
action: actionTypes[data[2]],
value: unescapeCSS(data[4] || data[5] || ""),
ignoreCase: !!data[6]
});
} else if(firstChar === ":"){
//if(selector.charAt(0) === ":"){} //TODO pseudo-element
name = getName().toLowerCase();
data = null;
if(selector.charAt(0) === "("){
var pos = getClosingPos(selector);
data = selector.substr(1, pos - 2);
selector = selector.substr(pos);
}
tokens.push({type: "pseudo", name: name, data: data});
} else {
//otherwise, the parser needs to throw or it would enter an infinite loop
throw new SyntaxError("Unmatched selector: " + firstChar + selector);
}
}
}
if(subselects.length > 0 && tokens.length === 0){
throw new SyntaxError("empty sub-selector");
}
subselects.push(tokens);
return subselects;
}

99
node_modules/css-what/package.json generated vendored Normal file
View File

@ -0,0 +1,99 @@
{
"_args": [
[
"css-what@1.0",
"/Users/okennedy/Documents/Website/node_modules/css-select"
]
],
"_from": "css-what@>=1.0.0 <1.1.0",
"_id": "css-what@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/css-what",
"_nodeVersion": "1.0.4",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "2.4.1",
"_phantomChildren": {},
"_requested": {
"name": "css-what",
"raw": "css-what@1.0",
"rawSpec": "1.0",
"scope": null,
"spec": ">=1.0.0 <1.1.0",
"type": "range"
},
"_requiredBy": [
"/css-select"
],
"_resolved": "https://registry.npmjs.org/css-what/-/css-what-1.0.0.tgz",
"_shasum": "d7cc2df45180666f99d2b14462639469e00f736c",
"_shrinkwrap": null,
"_spec": "css-what@1.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/css-select",
"author": {
"email": "me@feedic.com",
"name": "Felix Böhm",
"url": "http://feedic.com"
},
"bugs": {
"url": "https://github.com/fb55/css-what/issues"
},
"dependencies": {},
"description": "a CSS selector parser",
"devDependencies": {
"jshint": "2"
},
"directories": {},
"dist": {
"shasum": "d7cc2df45180666f99d2b14462639469e00f736c",
"tarball": "http://registry.npmjs.org/css-what/-/css-what-1.0.0.tgz"
},
"engines": {
"node": "*"
},
"files": [
"index.js"
],
"gitHead": "d54c2857acbb22d56190fc998b48744597ddd730",
"homepage": "https://github.com/fb55/css-what",
"jshintConfig": {
"eqeqeq": true,
"eqnull": true,
"freeze": true,
"globals": {
"describe": true,
"it": true
},
"latedef": "nofunc",
"noarg": true,
"node": true,
"nonbsp": true,
"proto": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
"unused": true
},
"license": "BSD-like",
"main": "./index.js",
"maintainers": [
{
"name": "feedic",
"email": "me@feedic.com"
}
],
"name": "css-what",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"url": "git+https://github.com/fb55/css-what.git"
},
"scripts": {
"test": "node tests/test.js && jshint *.js"
},
"version": "1.0.0"
}

46
node_modules/css-what/readme.md generated vendored Normal file
View File

@ -0,0 +1,46 @@
# css-what [![Build Status](https://secure.travis-ci.org/fb55/css-what.svg?branch=master)](http://travis-ci.org/fb55/css-what)
a CSS selector parser
## Example
```js
require('css-what')('foo[bar]:baz')
~> [ [ { type: 'tag', name: 'foo' },
{ type: 'attribute',
name: 'bar',
action: 'exists',
value: '',
ignoreCase: false },
{ type: 'pseudo',
name: 'baz',
data: null } ] ]
```
## API
__`CSSwhat(selector, options)` - Parses `str`, with the passed `options`.__
The function returns a two-dimensional array. The first array represents selectors separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:
name | attributes | example | output
---- | ---------- | ------- | ------
`tag`| `name` | `div` | `{ type: 'tag', name: 'div' }`
`universal`| - | `*` | `{ type: 'universal' }`
`pseudo`| `name`, `data`|`:name(data)`| `{ type: 'pseudo', name: 'name', data: 'data' }`
`pseudo`| `name`, `data`|`:name`| `{ type: 'pseudo', name: 'name', data: null }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr]`|`{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr=val]`|`{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr^=val]`|`{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }`
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr$=val]`|`{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }`
//TODO complete list
__Options:__
- `xmlMode`: When enabled, tag names will be case-sensitive (meaning they won't be lowercased).
---
License: BSD-like

23
node_modules/debug-log/index.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
'use strict';
// https://github.com/joyent/node/blob/fbfe562d71ae8d8f8bbf627808c755e513e4e905/lib/util.js#L96-L114
var util = require('util');
var debugEnv = process.env.NODE_DEBUG || '';
var cache = {};
module.exports = function (set) {
set = set.toUpperCase();
if (!cache[set]) {
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnv)) {
var pid = process.pid;
cache[set] = function () {
console.error('%s %d: %s', set, pid, util.format.apply(util, arguments));
};
} else {
cache[set] = function () {};
}
}
return cache[set];
};

93
node_modules/debug-log/package.json generated vendored Normal file
View File

@ -0,0 +1,93 @@
{
"_args": [
[
"debug-log@^1.0.0",
"/Users/okennedy/Documents/Website/node_modules/metalsmith-paths"
]
],
"_from": "debug-log@>=1.0.0 <2.0.0",
"_id": "debug-log@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/debug-log",
"_npmUser": {
"email": "sindresorhus@gmail.com",
"name": "sindresorhus"
},
"_npmVersion": "1.4.28",
"_phantomChildren": {},
"_requested": {
"name": "debug-log",
"raw": "debug-log@^1.0.0",
"rawSpec": "^1.0.0",
"scope": null,
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/metalsmith-paths"
],
"_resolved": "https://registry.npmjs.org/debug-log/-/debug-log-1.0.0.tgz",
"_shasum": "ea520801b4b78181b98c9499452580c34c4f0bfe",
"_shrinkwrap": null,
"_spec": "debug-log@^1.0.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/metalsmith-paths",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/debug-log/issues"
},
"dependencies": {},
"description": "Node.js 0.12 util.debuglog() ponyfill",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "ea520801b4b78181b98c9499452580c34c4f0bfe",
"tarball": "http://registry.npmjs.org/debug-log/-/debug-log-1.0.0.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"gitHead": "ebb0cab98e0b0aa80b3d54f3a454721270101ab5",
"homepage": "https://github.com/sindresorhus/debug-log",
"keywords": [
"built-in",
"console",
"core",
"debug",
"debuglog",
"env",
"environment",
"log",
"logging",
"polyfill",
"ponyfill",
"shim",
"util",
"utils"
],
"license": "MIT",
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "debug-log",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/debug-log.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.0.0"
}

42
node_modules/debug-log/readme.md generated vendored Normal file
View File

@ -0,0 +1,42 @@
# debug-log [![Build Status](https://travis-ci.org/sindresorhus/debug-log.svg?branch=master)](https://travis-ci.org/sindresorhus/debug-log)
> Node.js 0.12 [`util.debuglog()`](http://nodejs.org/docs/v0.11.15/api/util.html#util_util_debuglog_section) ponyfill
> Ponyfill: A polyfill that doesn't overwrite the native method
## Install
```
$ npm install --save debug-log
```
## Usage
```js
// example.js
var debugLog = require('debug-log')('foo');
debugLog('unicorns & rainbows');
```
```
$ node example.js
```
```
$ NODE_DEBUG=foo node example.js
FOO 3245: unicorns & rainbows
```
## API
See the [`util.debuglog()` docs](http://nodejs.org/docs/v0.11.15/api/util.html#util_util_debuglog_section).
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

11
node_modules/dom-serializer/LICENSE generated vendored Normal file
View File

@ -0,0 +1,11 @@
License
(The MIT License)
Copyright (c) 2014 The cheeriojs contributors
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.

178
node_modules/dom-serializer/index.js generated vendored Normal file
View File

@ -0,0 +1,178 @@
/*
Module dependencies
*/
var ElementType = require('domelementtype');
var entities = require('entities');
/*
Boolean Attributes
*/
var booleanAttributes = {
__proto__: null,
allowfullscreen: true,
async: true,
autofocus: true,
autoplay: true,
checked: true,
controls: true,
default: true,
defer: true,
disabled: true,
hidden: true,
ismap: true,
loop: true,
multiple: true,
muted: true,
open: true,
readonly: true,
required: true,
reversed: true,
scoped: true,
seamless: true,
selected: true,
typemustmatch: true
};
var unencodedElements = {
__proto__: null,
style: true,
script: true,
xmp: true,
iframe: true,
noembed: true,
noframes: true,
plaintext: true,
noscript: true
};
/*
Format attributes
*/
function formatAttrs(attributes, opts) {
if (!attributes) return;
var output = '',
value;
// Loop through the attributes
for (var key in attributes) {
value = attributes[key];
if (output) {
output += ' ';
}
if (!value && booleanAttributes[key]) {
output += key;
} else {
output += key + '="' + (opts.decodeEntities ? entities.encodeXML(value) : value) + '"';
}
}
return output;
}
/*
Self-enclosing tags (stolen from node-htmlparser)
*/
var singleTag = {
__proto__: null,
area: true,
base: true,
basefont: true,
br: true,
col: true,
command: true,
embed: true,
frame: true,
hr: true,
img: true,
input: true,
isindex: true,
keygen: true,
link: true,
meta: true,
param: true,
source: true,
track: true,
wbr: true,
};
var render = module.exports = function(dom, opts) {
if (!Array.isArray(dom) && !dom.cheerio) dom = [dom];
opts = opts || {};
var output = '';
for(var i = 0; i < dom.length; i++){
var elem = dom[i];
if (elem.type === 'root')
output += render(elem.children, opts);
else if (ElementType.isTag(elem))
output += renderTag(elem, opts);
else if (elem.type === ElementType.Directive)
output += renderDirective(elem);
else if (elem.type === ElementType.Comment)
output += renderComment(elem);
else if (elem.type === ElementType.CDATA)
output += renderCdata(elem);
else
output += renderText(elem, opts);
}
return output;
};
function renderTag(elem, opts) {
// Handle SVG
if (elem.name === "svg") opts = {decodeEntities: opts.decodeEntities, xmlMode: true};
var tag = '<' + elem.name,
attribs = formatAttrs(elem.attribs, opts);
if (attribs) {
tag += ' ' + attribs;
}
if (
opts.xmlMode
&& (!elem.children || elem.children.length === 0)
) {
tag += '/>';
} else {
tag += '>';
if (elem.children) {
tag += render(elem.children, opts);
}
if (!singleTag[elem.name] || opts.xmlMode) {
tag += '</' + elem.name + '>';
}
}
return tag;
}
function renderDirective(elem) {
return '<' + elem.data + '>';
}
function renderText(elem, opts) {
var data = elem.data || '';
// if entities weren't decoded, no need to encode them back
if (opts.decodeEntities && !(elem.parent && elem.parent.name in unencodedElements)) {
data = entities.encodeXML(data);
}
return data;
}
function renderCdata(elem) {
return '<![CDATA[' + elem.children[0].data + ']]>';
}
function renderComment(elem) {
return '<!--' + elem.data + '-->';
}

View File

@ -0,0 +1,11 @@
Copyright (c) Felix Böhm
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,14 @@
//Types of elements found in the DOM
module.exports = {
Text: "text", //Text
Directive: "directive", //<? ... ?>
Comment: "comment", //<!-- ... -->
Script: "script", //<script> tags
Style: "style", //<style> tags
Tag: "tag", //Any tag
CDATA: "cdata", //<![CDATA[ ... ]]>
isTag: function(elem){
return elem.type === "tag" || elem.type === "script" || elem.type === "style";
}
};

View File

@ -0,0 +1,73 @@
{
"_args": [
[
"domelementtype@~1.1.1",
"/Users/okennedy/Documents/Website/node_modules/dom-serializer"
]
],
"_from": "domelementtype@>=1.1.1 <1.2.0",
"_id": "domelementtype@1.1.3",
"_inCache": true,
"_installable": true,
"_location": "/dom-serializer/domelementtype",
"_nodeVersion": "0.10.32",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "2.1.5",
"_phantomChildren": {},
"_requested": {
"name": "domelementtype",
"raw": "domelementtype@~1.1.1",
"rawSpec": "~1.1.1",
"scope": null,
"spec": ">=1.1.1 <1.2.0",
"type": "range"
},
"_requiredBy": [
"/dom-serializer"
],
"_resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz",
"_shasum": "bd28773e2642881aec51544924299c5cd822185b",
"_shrinkwrap": null,
"_spec": "domelementtype@~1.1.1",
"_where": "/Users/okennedy/Documents/Website/node_modules/dom-serializer",
"author": {
"email": "me@feedic.com",
"name": "Felix Boehm"
},
"bugs": {
"url": "https://github.com/FB55/domelementtype/issues"
},
"dependencies": {},
"description": "all the types of nodes in htmlparser2's dom",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "bd28773e2642881aec51544924299c5cd822185b",
"tarball": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz"
},
"gitHead": "012a97a1d38737e096de2045b2b5f28768d8187e",
"homepage": "https://github.com/FB55/domelementtype",
"keywords": [
"dom",
"htmlparser2"
],
"main": "index.js",
"maintainers": [
{
"name": "feedic",
"email": "me@feedic.com"
}
],
"name": "domelementtype",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/FB55/domelementtype.git"
},
"scripts": {},
"version": "1.1.3"
}

View File

@ -0,0 +1 @@
all the types of nodes in htmlparser2's dom

99
node_modules/dom-serializer/package.json generated vendored Normal file
View File

@ -0,0 +1,99 @@
{
"_args": [
[
"dom-serializer@~0.1.0",
"/Users/okennedy/Documents/Website/node_modules/cheerio"
]
],
"_from": "dom-serializer@>=0.1.0 <0.2.0",
"_id": "dom-serializer@0.1.0",
"_inCache": true,
"_installable": true,
"_location": "/dom-serializer",
"_nodeVersion": "1.2.0",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "2.4.1",
"_phantomChildren": {},
"_requested": {
"name": "dom-serializer",
"raw": "dom-serializer@~0.1.0",
"rawSpec": "~0.1.0",
"scope": null,
"spec": ">=0.1.0 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/cheerio",
"/htmlparser2/domutils"
],
"_resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz",
"_shasum": "073c697546ce0780ce23be4a28e293e40bc30c82",
"_shrinkwrap": null,
"_spec": "dom-serializer@~0.1.0",
"_where": "/Users/okennedy/Documents/Website/node_modules/cheerio",
"author": {
"email": "me@feedic.com",
"name": "Felix Boehm"
},
"bugs": {
"url": "https://github.com/cheeriojs/dom-renderer/issues"
},
"dependencies": {
"domelementtype": "~1.1.1",
"entities": "~1.1.1"
},
"description": "render dom nodes to string",
"devDependencies": {
"cheerio": "*",
"expect.js": "~0.3.1",
"jshint": "~2.3.0",
"lodash": "~2.4.1",
"mocha": "*",
"xyz": "0.4.x"
},
"directories": {},
"dist": {
"shasum": "073c697546ce0780ce23be4a28e293e40bc30c82",
"tarball": "http://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz"
},
"files": [
"index.js"
],
"gitHead": "249b9a921e6ba318c52b87de21e8475bcb4050e5",
"homepage": "https://github.com/cheeriojs/dom-renderer",
"keywords": [
"html",
"render",
"xml"
],
"license": "MIT",
"main": "./index.js",
"maintainers": [
{
"name": "feedic",
"email": "me@feedic.com"
},
{
"name": "davidchambers",
"email": "dc@davidchambers.me"
},
{
"name": "mattmueller",
"email": "mattmuelle@gmail.com"
}
],
"name": "dom-serializer",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/cheeriojs/dom-renderer.git"
},
"scripts": {
"test": "mocha test.js"
},
"version": "0.1.0"
}

11
node_modules/domelementtype/LICENSE generated vendored Normal file
View File

@ -0,0 +1,11 @@
Copyright (c) Felix Böhm
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

15
node_modules/domelementtype/index.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
//Types of elements found in the DOM
module.exports = {
Text: "text", //Text
Directive: "directive", //<? ... ?>
Comment: "comment", //<!-- ... -->
Script: "script", //<script> tags
Style: "style", //<style> tags
Tag: "tag", //Any tag
CDATA: "cdata", //<![CDATA[ ... ]]>
Doctype: "doctype",
isTag: function(elem){
return elem.type === "tag" || elem.type === "script" || elem.type === "style";
}
};

76
node_modules/domelementtype/package.json generated vendored Normal file
View File

@ -0,0 +1,76 @@
{
"_args": [
[
"domelementtype@1",
"/Users/okennedy/Documents/Website/node_modules/domutils"
]
],
"_from": "domelementtype@>=1.0.0 <2.0.0",
"_id": "domelementtype@1.3.0",
"_inCache": true,
"_installable": true,
"_location": "/domelementtype",
"_nodeVersion": "1.4.2",
"_npmUser": {
"email": "me@feedic.com",
"name": "feedic"
},
"_npmVersion": "2.6.1",
"_phantomChildren": {},
"_requested": {
"name": "domelementtype",
"raw": "domelementtype@1",
"rawSpec": "1",
"scope": null,
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/domhandler",
"/domutils",
"/htmlparser2",
"/htmlparser2/domutils"
],
"_resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz",
"_shasum": "b17aed82e8ab59e52dd9c19b1756e0fc187204c2",
"_shrinkwrap": null,
"_spec": "domelementtype@1",
"_where": "/Users/okennedy/Documents/Website/node_modules/domutils",
"author": {
"email": "me@feedic.com",
"name": "Felix Boehm"
},
"bugs": {
"url": "https://github.com/FB55/domelementtype/issues"
},
"dependencies": {},
"description": "all the types of nodes in htmlparser2's dom",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "b17aed82e8ab59e52dd9c19b1756e0fc187204c2",
"tarball": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz"
},
"gitHead": "2a95eed4c829ef479a88984d117cb5f4b379e6e8",
"homepage": "https://github.com/FB55/domelementtype",
"keywords": [
"dom",
"htmlparser2"
],
"main": "index.js",
"maintainers": [
{
"name": "feedic",
"email": "me@feedic.com"
}
],
"name": "domelementtype",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/FB55/domelementtype.git"
},
"scripts": {},
"version": "1.3.0"
}

1
node_modules/domelementtype/readme.md generated vendored Normal file
View File

@ -0,0 +1 @@
all the types of nodes in htmlparser2's dom

7
node_modules/domhandler/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,7 @@
before_install:
- '[ "${TRAVIS_NODE_VERSION}" != "0.8" ] || npm install -g npm@1.4.28'
- npm install -g npm@latest
language: node_js
node_js:
- 0.8
- 0.10

11
node_modules/domhandler/LICENSE generated vendored Normal file
View File

@ -0,0 +1,11 @@
Copyright (c) Felix Böhm
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

182
node_modules/domhandler/index.js generated vendored Normal file
View File

@ -0,0 +1,182 @@
var ElementType = require("domelementtype");
var re_whitespace = /\s+/g;
var NodePrototype = require("./lib/node");
var ElementPrototype = require("./lib/element");
function DomHandler(callback, options, elementCB){
if(typeof callback === "object"){
elementCB = options;
options = callback;
callback = null;
} else if(typeof options === "function"){
elementCB = options;
options = defaultOpts;
}
this._callback = callback;
this._options = options || defaultOpts;
this._elementCB = elementCB;
this.dom = [];
this._done = false;
this._tagStack = [];
this._parser = this._parser || null;
}
//default options
var defaultOpts = {
normalizeWhitespace: false, //Replace all whitespace with single spaces
withStartIndices: false, //Add startIndex properties to nodes
};
DomHandler.prototype.onparserinit = function(parser){
this._parser = parser;
};
//Resets the handler back to starting state
DomHandler.prototype.onreset = function(){
DomHandler.call(this, this._callback, this._options, this._elementCB);
};
//Signals the handler that parsing is done
DomHandler.prototype.onend = function(){
if(this._done) return;
this._done = true;
this._parser = null;
this._handleCallback(null);
};
DomHandler.prototype._handleCallback =
DomHandler.prototype.onerror = function(error){
if(typeof this._callback === "function"){
this._callback(error, this.dom);
} else {
if(error) throw error;
}
};
DomHandler.prototype.onclosetag = function(){
//if(this._tagStack.pop().name !== name) this._handleCallback(Error("Tagname didn't match!"));
var elem = this._tagStack.pop();
if(this._elementCB) this._elementCB(elem);
};
DomHandler.prototype._addDomElement = function(element){
var parent = this._tagStack[this._tagStack.length - 1];
var siblings = parent ? parent.children : this.dom;
var previousSibling = siblings[siblings.length - 1];
element.next = null;
if(this._options.withStartIndices){
element.startIndex = this._parser.startIndex;
}
if (this._options.withDomLvl1) {
element.__proto__ = element.type === "tag" ? ElementPrototype : NodePrototype;
}
if(previousSibling){
element.prev = previousSibling;
previousSibling.next = element;
} else {
element.prev = null;
}
siblings.push(element);
element.parent = parent || null;
};
DomHandler.prototype.onopentag = function(name, attribs){
var element = {
type: name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag,
name: name,
attribs: attribs,
children: []
};
this._addDomElement(element);
this._tagStack.push(element);
};
DomHandler.prototype.ontext = function(data){
//the ignoreWhitespace is officially dropped, but for now,
//it's an alias for normalizeWhitespace
var normalize = this._options.normalizeWhitespace || this._options.ignoreWhitespace;
var lastTag;
if(!this._tagStack.length && this.dom.length && (lastTag = this.dom[this.dom.length-1]).type === ElementType.Text){
if(normalize){
lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
} else {
lastTag.data += data;
}
} else {
if(
this._tagStack.length &&
(lastTag = this._tagStack[this._tagStack.length - 1]) &&
(lastTag = lastTag.children[lastTag.children.length - 1]) &&
lastTag.type === ElementType.Text
){
if(normalize){
lastTag.data = (lastTag.data + data).replace(re_whitespace, " ");
} else {
lastTag.data += data;
}
} else {
if(normalize){
data = data.replace(re_whitespace, " ");
}
this._addDomElement({
data: data,
type: ElementType.Text
});
}
}
};
DomHandler.prototype.oncomment = function(data){
var lastTag = this._tagStack[this._tagStack.length - 1];
if(lastTag && lastTag.type === ElementType.Comment){
lastTag.data += data;
return;
}
var element = {
data: data,
type: ElementType.Comment
};
this._addDomElement(element);
this._tagStack.push(element);
};
DomHandler.prototype.oncdatastart = function(){
var element = {
children: [{
data: "",
type: ElementType.Text
}],
type: ElementType.CDATA
};
this._addDomElement(element);
this._tagStack.push(element);
};
DomHandler.prototype.oncommentend = DomHandler.prototype.oncdataend = function(){
this._tagStack.pop();
};
DomHandler.prototype.onprocessinginstruction = function(name, data){
this._addDomElement({
name: name,
data: data,
type: ElementType.Directive
});
};
module.exports = DomHandler;

20
node_modules/domhandler/lib/element.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
// DOM-Level-1-compliant structure
var NodePrototype = require('./node');
var ElementPrototype = module.exports = Object.create(NodePrototype);
var domLvl1 = {
tagName: "name"
};
Object.keys(domLvl1).forEach(function(key) {
var shorthand = domLvl1[key];
Object.defineProperty(ElementPrototype, key, {
get: function() {
return this[shorthand] || null;
},
set: function(val) {
this[shorthand] = val;
return val;
}
});
});

44
node_modules/domhandler/lib/node.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
// This object will be used as the prototype for Nodes when creating a
// DOM-Level-1-compliant structure.
var NodePrototype = module.exports = {
get firstChild() {
var children = this.children;
return children && children[0] || null;
},
get lastChild() {
var children = this.children;
return children && children[children.length - 1] || null;
},
get nodeType() {
return nodeTypes[this.type] || nodeTypes.element;
}
};
var domLvl1 = {
tagName: "name",
childNodes: "children",
parentNode: "parent",
previousSibling: "prev",
nextSibling: "next",
nodeValue: "data"
};
var nodeTypes = {
element: 1,
text: 3,
cdata: 4,
comment: 8
};
Object.keys(domLvl1).forEach(function(key) {
var shorthand = domLvl1[key];
Object.defineProperty(NodePrototype, key, {
get: function() {
return this[shorthand] || null;
},
set: function(val) {
this[shorthand] = val;
return val;
}
});
});

Some files were not shown because too many files have changed in this diff Show More