WIP - add extractor, generate snippet_data
This commit is contained in:
35
node_modules/nlcst-to-string/index.js
generated
vendored
Normal file
35
node_modules/nlcst-to-string/index.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = nlcstToString
|
||||
|
||||
// Stringify one nlcst node or list of nodes.
|
||||
function nlcstToString(node, separator) {
|
||||
var sep = separator || ''
|
||||
var values
|
||||
var length
|
||||
var children
|
||||
|
||||
if (!node || (!('length' in node) && !node.type)) {
|
||||
throw new Error('Expected node, not `' + node + '`')
|
||||
}
|
||||
|
||||
if (typeof node.value === 'string') {
|
||||
return node.value
|
||||
}
|
||||
|
||||
children = 'length' in node ? node : node.children
|
||||
length = children.length
|
||||
|
||||
// Shortcut: This is pretty common, and a small performance win.
|
||||
if (length === 1 && 'value' in children[0]) {
|
||||
return children[0].value
|
||||
}
|
||||
|
||||
values = []
|
||||
|
||||
while (length--) {
|
||||
values[length] = nlcstToString(children[length], sep)
|
||||
}
|
||||
|
||||
return values.join(sep)
|
||||
}
|
||||
22
node_modules/nlcst-to-string/license
generated
vendored
Normal file
22
node_modules/nlcst-to-string/license
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 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/nlcst-to-string/package.json
generated
vendored
Normal file
113
node_modules/nlcst-to-string/package.json
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
{
|
||||
"_from": "nlcst-to-string@^2.0.0",
|
||||
"_id": "nlcst-to-string@2.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-OY2QhGdf6jpYfHqS4vJwqF7aIBZkaMjMUkcHcskMPitvXLuYNGdQvgVWI/5yKwkmIdmhft3ounSJv+Re2yydng==",
|
||||
"_location": "/nlcst-to-string",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "nlcst-to-string@^2.0.0",
|
||||
"name": "nlcst-to-string",
|
||||
"escapedName": "nlcst-to-string",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mdast-util-to-nlcst",
|
||||
"/parse-english",
|
||||
"/parse-latin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/nlcst-to-string/-/nlcst-to-string-2.0.3.tgz",
|
||||
"_shasum": "b7913bb1305263b0561a86de68e179f17f7febe3",
|
||||
"_spec": "nlcst-to-string@^2.0.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/mdast-util-to-nlcst",
|
||||
"author": {
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/syntax-tree/nlcst-to-string/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
{
|
||||
"name": "Kenichiro Murata",
|
||||
"email": "kenichiro.murata@gmail.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Stringify NLCST",
|
||||
"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.5.0",
|
||||
"unist-builder": "^1.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/syntax-tree/nlcst-to-string#readme",
|
||||
"keywords": [
|
||||
"nlcst",
|
||||
"retext",
|
||||
"to",
|
||||
"string"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "nlcst-to-string",
|
||||
"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/nlcst-to-string.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"build-bundle": "browserify . -s nlcstToString -o nlcst-to-string.js",
|
||||
"build-mangle": "browserify . -s nlcstToString -p tinyify -o nlcst-to-string.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": "2.0.3",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignore": [
|
||||
"nlcst-to-string.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
110
node_modules/nlcst-to-string/readme.md
generated
vendored
Normal file
110
node_modules/nlcst-to-string/readme.md
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
# nlcst-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]
|
||||
|
||||
[**nlcst**][nlcst] utility to stringify a node.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install nlcst-to-string
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var toString = require('nlcst-to-string')
|
||||
|
||||
console.log(
|
||||
toString({
|
||||
type: 'WordNode',
|
||||
children: [
|
||||
{type: 'TextNode', value: 'AT'},
|
||||
{type: 'PunctuationNode', value: '&'},
|
||||
{type: 'TextNode', value: 'T'}
|
||||
]
|
||||
})
|
||||
) // => 'AT&T'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `toString(node[, separator])`
|
||||
|
||||
Stringify the given [nlcst][] node (or list of nodes).
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `node` ([`Node`][node] or `Array.<Node>`)
|
||||
* `separator` (`string`, optional, default: `''`)
|
||||
— Value to delimit each item
|
||||
|
||||
###### Returns
|
||||
|
||||
`string`.
|
||||
|
||||
## 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/nlcst-to-string.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/nlcst-to-string
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/nlcst-to-string.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/nlcst-to-string
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/nlcst-to-string.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/nlcst-to-string
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/nlcst-to-string.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=nlcst-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/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
|
||||
|
||||
[nlcst]: https://github.com/syntax-tree/nlcst
|
||||
|
||||
[node]: https://github.com/syntax-tree/nlcst#nodes
|
||||
Reference in New Issue
Block a user