WIP - add extractor, generate snippet_data
This commit is contained in:
29
node_modules/unist-util-visit/index.js
generated
vendored
Normal file
29
node_modules/unist-util-visit/index.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = visit
|
||||
|
||||
var visitParents = require('unist-util-visit-parents')
|
||||
|
||||
var CONTINUE = visitParents.CONTINUE
|
||||
var SKIP = visitParents.SKIP
|
||||
var EXIT = visitParents.EXIT
|
||||
|
||||
visit.CONTINUE = CONTINUE
|
||||
visit.SKIP = SKIP
|
||||
visit.EXIT = EXIT
|
||||
|
||||
function visit(tree, test, visitor, reverse) {
|
||||
if (typeof test === 'function' && typeof visitor !== 'function') {
|
||||
reverse = visitor
|
||||
visitor = test
|
||||
test = null
|
||||
}
|
||||
|
||||
visitParents(tree, test, overload, reverse)
|
||||
|
||||
function overload(node, parents) {
|
||||
var parent = parents[parents.length - 1]
|
||||
var index = parent ? parent.children.indexOf(node) : null
|
||||
return visitor(node, index, parent)
|
||||
}
|
||||
}
|
||||
22
node_modules/unist-util-visit/license
generated
vendored
Normal file
22
node_modules/unist-util-visit/license
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
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.
|
||||
131
node_modules/unist-util-visit/package.json
generated
vendored
Normal file
131
node_modules/unist-util-visit/package.json
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
{
|
||||
"_from": "unist-util-visit@^1.3.0",
|
||||
"_id": "unist-util-visit@1.4.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==",
|
||||
"_location": "/unist-util-visit",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "unist-util-visit@^1.3.0",
|
||||
"name": "unist-util-visit",
|
||||
"escapedName": "unist-util-visit",
|
||||
"rawSpec": "^1.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gatsby-remark-copy-linked-files",
|
||||
"/gatsby-remark-prismjs",
|
||||
"/gatsby-transformer-remark",
|
||||
"/mdast-util-compact",
|
||||
"/mdast-util-definitions",
|
||||
"/mdast-util-to-hast",
|
||||
"/mdast-util-toc",
|
||||
"/unist-util-remove-position"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz",
|
||||
"_shasum": "4724aaa8486e6ee6e26d7ff3c8685960d560b1e3",
|
||||
"_spec": "unist-util-visit@^1.3.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby-remark-copy-linked-files",
|
||||
"author": {
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/syntax-tree/unist-util-visit/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
{
|
||||
"name": "Eugene Sharygin",
|
||||
"email": "eush77@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Richard Gibson",
|
||||
"email": "richard.gibson@gmail.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"unist-util-visit-parents": "^2.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Recursively walk over unist nodes",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^14.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark": "^10.0.0",
|
||||
"remark-cli": "^6.0.0",
|
||||
"remark-preset-wooorm": "^5.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/syntax-tree/unist-util-visit#readme",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"remark",
|
||||
"markdown",
|
||||
"retext",
|
||||
"natural",
|
||||
"language",
|
||||
"node",
|
||||
"visit",
|
||||
"walk",
|
||||
"util",
|
||||
"utility"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "unist-util-visit",
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/syntax-tree/unist-util-visit.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"build-bundle": "browserify . -s unistUtilVisit > unist-util-visit.js",
|
||||
"build-mangle": "browserify . -s unistUtilVisit -p tinyify > unist-util-visit.min.js",
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"test": "npm run format && npm run build && npm run test-coverage",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js"
|
||||
},
|
||||
"version": "1.4.1",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignores": [
|
||||
"unist-util-visit.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
121
node_modules/unist-util-visit/readme.md
generated
vendored
Normal file
121
node_modules/unist-util-visit/readme.md
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
# unist-util-visit
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
|
||||
[**unist**][unist] utility to visit nodes.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```bash
|
||||
npm install unist-util-visit
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var u = require('unist-builder')
|
||||
var visit = require('unist-util-visit')
|
||||
|
||||
var tree = u('tree', [
|
||||
u('leaf', '1'),
|
||||
u('node', [u('leaf', '2')]),
|
||||
u('void'),
|
||||
u('leaf', '3')
|
||||
])
|
||||
|
||||
visit(tree, 'leaf', function(node) {
|
||||
console.log(node)
|
||||
})
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{ type: 'leaf', value: '1' }
|
||||
{ type: 'leaf', value: '2' }
|
||||
{ type: 'leaf', value: '3' }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `visit(tree[, test], visitor[, reverse])`
|
||||
|
||||
This function works exactly the same as [`unist-util-visit-parents`][vp],
|
||||
but `visitor` has a different signature.
|
||||
|
||||
#### `next? = visitor(node, index, parent)`
|
||||
|
||||
Instead of being passed an array of ancestors, `visitor` is invoked with the
|
||||
node’s [`index`][index] and its [`parent`][parent].
|
||||
|
||||
Otherwise the same as [`unist-util-visit-parents`][vp].
|
||||
|
||||
## Related
|
||||
|
||||
* [`unist-util-visit-parents`][vp]
|
||||
— Like `visit`, but with a stack of parents
|
||||
* [`unist-util-filter`](https://github.com/eush77/unist-util-filter)
|
||||
— Create a new tree with all nodes that pass a test
|
||||
* [`unist-util-map`](https://github.com/syntax-tree/unist-util-map)
|
||||
— Create a new tree with all nodes mapped by a given function
|
||||
* [`unist-util-remove`](https://github.com/eush77/unist-util-remove)
|
||||
— Remove nodes from a tree that pass a test
|
||||
* [`unist-util-select`](https://github.com/eush77/unist-util-select)
|
||||
— Select nodes with CSS-like selectors
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
|
||||
started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [Code of Conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definition -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-visit.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/unist-util-visit
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-visit.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-visit
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-visit.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unist-util-visit
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-visit.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unist-util-visit
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
|
||||
|
||||
[unist]: https://github.com/syntax-tree/unist
|
||||
|
||||
[vp]: https://github.com/syntax-tree/unist-util-visit-parents
|
||||
|
||||
[index]: https://github.com/syntax-tree/unist#index
|
||||
|
||||
[parent]: https://github.com/syntax-tree/unist#parent-1
|
||||
Reference in New Issue
Block a user