WIP - add extractor, generate snippet_data
This commit is contained in:
35
node_modules/unist-util-modify-children/index.js
generated
vendored
Normal file
35
node_modules/unist-util-modify-children/index.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict'
|
||||
|
||||
var iterate = require('array-iterate')
|
||||
|
||||
module.exports = modifierFactory
|
||||
|
||||
// Turn `callback` into a child-modifier accepting a parent. See
|
||||
// `array-iterate` for more info.
|
||||
function modifierFactory(callback) {
|
||||
return iteratorFactory(wrapperFactory(callback))
|
||||
}
|
||||
|
||||
// Turn `callback` into a `iterator' accepting a parent.
|
||||
function iteratorFactory(callback) {
|
||||
return iterator
|
||||
|
||||
function iterator(parent) {
|
||||
var children = parent && parent.children
|
||||
|
||||
if (!children) {
|
||||
throw new Error('Missing children in `parent` for `modifier`')
|
||||
}
|
||||
|
||||
return iterate(children, callback, parent)
|
||||
}
|
||||
}
|
||||
|
||||
// Pass the context as the third argument to `callback`.
|
||||
function wrapperFactory(callback) {
|
||||
return wrapper
|
||||
|
||||
function wrapper(value, index) {
|
||||
return callback(value, index, this)
|
||||
}
|
||||
}
|
||||
22
node_modules/unist-util-modify-children/license
generated
vendored
Normal file
22
node_modules/unist-util-modify-children/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.
|
||||
113
node_modules/unist-util-modify-children/package.json
generated
vendored
Normal file
113
node_modules/unist-util-modify-children/package.json
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
{
|
||||
"_from": "unist-util-modify-children@^1.0.0",
|
||||
"_id": "unist-util-modify-children@1.1.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-8iey9wkoB62C7Vi/8zcRUmi4b1f5AYKTwMkyEgLduo2D8+OY65RoSvbn6k9tVNri6qumXxAwXDVlXWQi0sENTw==",
|
||||
"_location": "/unist-util-modify-children",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "unist-util-modify-children@^1.0.0",
|
||||
"name": "unist-util-modify-children",
|
||||
"escapedName": "unist-util-modify-children",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/parse-english",
|
||||
"/parse-latin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/unist-util-modify-children/-/unist-util-modify-children-1.1.4.tgz",
|
||||
"_shasum": "f9dd31e93884c3be06b43c9291d60324d5df5f68",
|
||||
"_spec": "unist-util-modify-children@^1.0.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/parse-english",
|
||||
"author": {
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/syntax-tree/unist-util-modify-children/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"array-iterate": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Unist utility to modify direct children of a parent",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^14.0.0",
|
||||
"prettier": "^1.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-modify-children#readme",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"retext",
|
||||
"nlcst",
|
||||
"mdast",
|
||||
"util",
|
||||
"utility",
|
||||
"modify",
|
||||
"children"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "unist-util-modify-children",
|
||||
"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-modify-children.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"build-bundle": "browserify . -s unistUtilModifyChildren > unist-util-modify-children.js",
|
||||
"build-mangle": "browserify . -s unistUtilModifyChildren -p tinyify > unist-util-modify-children.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.1.4",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignore": [
|
||||
"unist-util-modify-children.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
154
node_modules/unist-util-modify-children/readme.md
generated
vendored
Normal file
154
node_modules/unist-util-modify-children/readme.md
generated
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
# unist-util-modify-children
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
Modify direct children of a parent.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install unist-util-modify-children
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var u = require('unist-builder')
|
||||
var modifyChildren = require('unist-util-modify-children')
|
||||
|
||||
var modify = modifyChildren(modifier)
|
||||
|
||||
var tree = u('root', [
|
||||
u('leaf', '1'),
|
||||
u('node', [u('leaf', '2')]),
|
||||
u('leaf', '3')
|
||||
])
|
||||
|
||||
modify(tree)
|
||||
|
||||
console.dir(tree, {depth: null})
|
||||
|
||||
function modifier(node, index, parent) {
|
||||
if (node.type === 'node') {
|
||||
parent.children.splice(index, 1, {type: 'subtree', children: node.children})
|
||||
return index + 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'root',
|
||||
children: [
|
||||
{ type: 'leaf', value: '1' },
|
||||
{ type: 'subtree', children: [ { type: 'leaf', value: '2' } ] },
|
||||
{ type: 'leaf', value: '3' }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `modify = modifyChildren(modifier)`
|
||||
|
||||
Wrap [`modifier`][modifier] to be invoked for each child in the node given to
|
||||
[`modify`][modify].
|
||||
|
||||
#### `next? = modifier(child, index, parent)`
|
||||
|
||||
Invoked if [`modify`][modify] is called on a parent node for each `child`
|
||||
in `parent`.
|
||||
|
||||
###### Returns
|
||||
|
||||
`number` (optional) — Next position to iterate.
|
||||
|
||||
#### `function modify(parent)`
|
||||
|
||||
Invoke the bound [`modifier`][modifier] for each child in `parent`
|
||||
([`Node`][node]).
|
||||
|
||||
## Related
|
||||
|
||||
* [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit)
|
||||
— Visit nodes
|
||||
* [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents)
|
||||
— Visit nodes with ancestral information
|
||||
* [`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]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-modify-children.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/unist-util-modify-children
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-modify-children.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-modify-children
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-modify-children.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unist-util-modify-children
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-modify-children.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unist-util-modify-children
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
|
||||
|
||||
[chat]: https://spectrum.chat/unified/syntax-tree
|
||||
|
||||
[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
|
||||
|
||||
[node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[modifier]: #next--modifierchild-index-parent
|
||||
|
||||
[modify]: #function-modifyparent
|
||||
Reference in New Issue
Block a user