This commit is contained in:
51
node_modules/mdast-util-definitions/index.js
generated
vendored
Normal file
51
node_modules/mdast-util-definitions/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict'
|
||||
|
||||
var visit = require('unist-util-visit')
|
||||
|
||||
module.exports = getDefinitionFactory
|
||||
|
||||
var own = {}.hasOwnProperty
|
||||
|
||||
// Get a definition in `node` by `identifier`.
|
||||
function getDefinitionFactory(node, options) {
|
||||
return getterFactory(gather(node, options))
|
||||
}
|
||||
|
||||
// Gather all definitions in `node`
|
||||
function gather(node, options) {
|
||||
var cache = {}
|
||||
|
||||
if (!node || !node.type) {
|
||||
throw new Error('mdast-util-definitions expected node')
|
||||
}
|
||||
|
||||
visit(node, 'definition', options && options.commonmark ? commonmark : normal)
|
||||
|
||||
return cache
|
||||
|
||||
function commonmark(definition) {
|
||||
var id = normalise(definition.identifier)
|
||||
if (!own.call(cache, id)) {
|
||||
cache[id] = definition
|
||||
}
|
||||
}
|
||||
|
||||
function normal(definition) {
|
||||
cache[normalise(definition.identifier)] = definition
|
||||
}
|
||||
}
|
||||
|
||||
// Factory to get a node from the given definition-cache.
|
||||
function getterFactory(cache) {
|
||||
return getter
|
||||
|
||||
// Get a node from the bound definition-cache.
|
||||
function getter(identifier) {
|
||||
var id = identifier && normalise(identifier)
|
||||
return id && own.call(cache, id) ? cache[id] : null
|
||||
}
|
||||
}
|
||||
|
||||
function normalise(identifier) {
|
||||
return identifier.toUpperCase()
|
||||
}
|
||||
22
node_modules/mdast-util-definitions/license
generated
vendored
Normal file
22
node_modules/mdast-util-definitions/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015-2016 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.
|
||||
77
node_modules/mdast-util-definitions/package.json
generated
vendored
Normal file
77
node_modules/mdast-util-definitions/package.json
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"name": "mdast-util-definitions",
|
||||
"version": "1.2.5",
|
||||
"description": "Find definition nodes in mdast nodes",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mdast",
|
||||
"remark",
|
||||
"markdown",
|
||||
"node",
|
||||
"definition",
|
||||
"find",
|
||||
"cache"
|
||||
],
|
||||
"repository": "syntax-tree/mdast-util-definitions",
|
||||
"bugs": "https://github.com/syntax-tree/mdast-util-definitions/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unist-util-visit": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^14.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark": "^11.0.0",
|
||||
"remark-cli": "^7.0.0",
|
||||
"remark-preset-wooorm": "^6.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"xo": "^0.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"build-bundle": "browserify . -s mdastUtilDefinitions > mdast-util-definitions.js",
|
||||
"build-mangle": "browserify . -s mdastUtilDefinitions -p tinyify > mdast-util-definitions.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run format && npm run build && npm run test-coverage"
|
||||
},
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignore": [
|
||||
"mdast-util-definitions.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
139
node_modules/mdast-util-definitions/readme.md
generated
vendored
Normal file
139
node_modules/mdast-util-definitions/readme.md
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
# mdast-util-definitions
|
||||
|
||||
[![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]
|
||||
|
||||
[**mdast**][mdast] utility to get definitions by `identifier`.
|
||||
|
||||
Supports funky keys, like `__proto__` or `toString`.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install mdast-util-definitions
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var remark = require('remark')
|
||||
var definitions = require('mdast-util-definitions')
|
||||
|
||||
var ast = remark().parse('[example]: https://example.com "Example"')
|
||||
|
||||
var definition = definitions(ast)
|
||||
|
||||
definition('example')
|
||||
// => {type: 'definition', 'title': 'Example', ...}
|
||||
|
||||
definition('foo')
|
||||
// => null
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `definitions(node[, options])`
|
||||
|
||||
Create a cache of all [definition][]s in [`node`][node].
|
||||
|
||||
###### `options.commonmark`
|
||||
|
||||
`boolean`, default: false — Turn on to use CommonMark precedence: ignore
|
||||
definitions found later for duplicate definitions.
|
||||
The default behaviour is to prefer the last found definition.
|
||||
|
||||
###### Returns
|
||||
|
||||
[`Function`][fn-definition]
|
||||
|
||||
### `definition(identifier)`
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `identifier` (`string`) — [Identifier][] of [definition][].
|
||||
|
||||
###### Returns
|
||||
|
||||
[`Node?`][node] — [Definition][], if found.
|
||||
|
||||
## Security
|
||||
|
||||
Use of `mdast-util-definitions` does not involve [**hast**][hast] or user
|
||||
content so there are no openings for [cross-site scripting (XSS)][xss] attacks.
|
||||
|
||||
Additionally, safe guards are in place to protect against prototype poisoning.
|
||||
|
||||
## 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/mdast-util-definitions.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/mdast-util-definitions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-definitions.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-definitions
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-definitions.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/mdast-util-definitions
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-definitions.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=mdast-util-definitions
|
||||
|
||||
[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
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[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
|
||||
|
||||
[mdast]: https://github.com/syntax-tree/mdast
|
||||
|
||||
[node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[fn-definition]: #definitionidentifier
|
||||
|
||||
[definition]: https://github.com/syntax-tree/mdast#definition
|
||||
|
||||
[identifier]: https://github.com/syntax-tree/mdast#association
|
||||
|
||||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||
|
||||
[hast]: https://github.com/syntax-tree/hast
|
||||
Reference in New Issue
Block a user