diff options
author | Rich Trott <rtrott@gmail.com> | 2021-11-27 09:36:35 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2021-11-29 14:52:42 -0800 |
commit | 4c41fea7a76949bce58adc7ce30ad952e2088401 (patch) | |
tree | c5e47fff5d755cb7f7e9e41d6d27e90d151e7589 /tools/node_modules/eslint/node_modules/mdast-util-to-string | |
parent | 6fd0a60d6078f5e409077c4ca5856e939922308b (diff) | |
download | node-new-4c41fea7a76949bce58adc7ce30ad952e2088401.tar.gz |
tools: consolidate ESLint dependencies
PR-URL: https://github.com/nodejs/node/pull/40995
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/node_modules/mdast-util-to-string')
4 files changed, 258 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/mdast-util-to-string/index.js b/tools/node_modules/eslint/node_modules/mdast-util-to-string/index.js new file mode 100644 index 0000000000..0ae5f1dbdb --- /dev/null +++ b/tools/node_modules/eslint/node_modules/mdast-util-to-string/index.js @@ -0,0 +1,29 @@ +'use strict' + +module.exports = toString + +// Get the text content of a node. +// Prefer the node’s plain-text fields, otherwise serialize its children, +// and if the given value is an array, serialize the nodes in it. +function toString(node) { + return ( + (node && + (node.value || + node.alt || + node.title || + ('children' in node && all(node.children)) || + ('length' in node && all(node)))) || + '' + ) +} + +function all(values) { + var result = [] + var index = -1 + + while (++index < values.length) { + result[index] = toString(values[index]) + } + + return result.join('') +} diff --git a/tools/node_modules/eslint/node_modules/mdast-util-to-string/license b/tools/node_modules/eslint/node_modules/mdast-util-to-string/license new file mode 100644 index 0000000000..32e7a3d93c --- /dev/null +++ b/tools/node_modules/eslint/node_modules/mdast-util-to-string/license @@ -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. diff --git a/tools/node_modules/eslint/node_modules/mdast-util-to-string/package.json b/tools/node_modules/eslint/node_modules/mdast-util-to-string/package.json new file mode 100644 index 0000000000..124287e297 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/mdast-util-to-string/package.json @@ -0,0 +1,80 @@ +{ + "name": "mdast-util-to-string", + "version": "2.0.0", + "description": "mdast utility to get the plain text content of a node", + "license": "MIT", + "keywords": [ + "unist", + "mdast", + "mdast-util", + "util", + "utility", + "markdown", + "node", + "string", + "serialize" + ], + "repository": "syntax-tree/mdast-util-to-string", + "bugs": "https://github.com/syntax-tree/mdast-util-to-string/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", + "types/index.d.ts" + ], + "types": "types/index.d.ts", + "devDependencies": { + "browserify": "^17.0.0", + "dtslint": "^4.0.0", + "nyc": "^15.0.0", + "prettier": "^2.0.0", + "remark-cli": "^9.0.0", + "remark-preset-wooorm": "^8.0.0", + "tape": "^5.0.0", + "tinyify": "^3.0.0", + "xo": "^0.34.0" + }, + "scripts": { + "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", + "build-bundle": "browserify . -s mdastUtilToString -o mdast-util-to-string.js", + "build-mangle": "browserify . -s mdastUtilToString -o mdast-util-to-string.min.js -p tinyify", + "build": "npm run build-bundle && npm run build-mangle", + "test-api": "node test", + "test-coverage": "nyc --reporter lcov tape test.js", + "test-types": "dtslint types", + "test": "npm run format && npm run build && npm run test-coverage && npm run test-types" + }, + "prettier": { + "tabWidth": 2, + "useTabs": false, + "singleQuote": true, + "bracketSpacing": false, + "semi": false, + "trailingComma": "none" + }, + "xo": { + "prettier": true, + "esnext": false, + "ignore": [ + "mdast-util-to-string.js", + "types/test.ts" + ] + }, + "nyc": { + "check-coverage": true, + "lines": 100, + "functions": 100, + "branches": 100 + }, + "remarkConfig": { + "plugins": [ + "preset-wooorm" + ] + } +} diff --git a/tools/node_modules/eslint/node_modules/mdast-util-to-string/readme.md b/tools/node_modules/eslint/node_modules/mdast-util-to-string/readme.md new file mode 100644 index 0000000000..2b7f1a0ed0 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/mdast-util-to-string/readme.md @@ -0,0 +1,127 @@ +# mdast-util-to-string + +[![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][]** utility to get the plain text content of a node. + +## Install + +[npm][]: + +```sh +npm install mdast-util-to-string +``` + +## Use + +```js +var unified = require('unified') +var parse = require('remark-parse') +var toString = require('mdast-util-to-string') + +var tree = unified() + .use(parse) + .parse('Some _emphasis_, **importance**, and `code`.') + +console.log(toString(tree)) // => 'Some emphasis, importance, and code.' +``` + +## API + +### `toString(node)` + +Get the text content of a [node][] or list of nodes. + +The algorithm checks `value` of `node`, then `alt`, and finally `title`. +If no value is found, the algorithm checks the children of `node` and joins them +(without spaces or newlines). + +> This is not a markdown to plain-text library. +> Use [`strip-markdown`][strip-markdown] for that. + +## Security + +Use of `mdast-util-to-string` does not involve **[hast][]**, user content, or +change the tree, so there are no openings for [cross-site scripting (XSS)][xss] +attacks. + +## Related + +* [`nlcst-to-string`](https://github.com/syntax-tree/nlcst-to-string) + — Get text content in nlcst +* [`hast-util-to-string`](https://github.com/wooorm/rehype-minify/tree/HEAD/packages/hast-util-to-string) + — Get text content in hast +* [`hast-util-to-text`](https://github.com/syntax-tree/hast-util-to-text) + — Get text content in hast according to the `innerText` algorithm +* [`hast-util-from-string`](https://github.com/wooorm/rehype-minify/tree/HEAD/packages/hast-util-from-string) + — Set text content in hast + +## 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, organization, or community you agree to +abide by its terms. + +## License + +[MIT][license] © [Titus Wormer][author] + +<!-- Definitions --> + +[build-badge]: https://github.com/syntax-tree/mdast-util-to-string/workflows/main/badge.svg + +[build]: https://github.com/syntax-tree/mdast-util-to-string/actions + +[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-to-string.svg + +[coverage]: https://codecov.io/github/syntax-tree/mdast-util-to-string + +[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-to-string.svg + +[downloads]: https://www.npmjs.com/package/mdast-util-to-string + +[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-string.svg + +[size]: https://bundlephobia.com/result?p=mdast-util-to-string + +[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/chat-discussions-success.svg + +[chat]: https://github.com/syntax-tree/unist/discussions + +[npm]: https://docs.npmjs.com/cli/install + +[license]: license + +[author]: https://wooorm.com + +[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md + +[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md + +[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md + +[mdast]: https://github.com/syntax-tree/mdast + +[node]: https://github.com/syntax-tree/mdast#nodes + +[strip-markdown]: https://github.com/remarkjs/strip-markdown + +[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting + +[hast]: https://github.com/syntax-tree/hast |