WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

61
node_modules/mdast-util-compact/index.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
'use strict'
var visit = require('unist-util-visit')
module.exports = compact
// Make an mdast tree compact by merging adjacent text nodes.
function compact(tree, commonmark) {
visit(tree, visitor)
return tree
function visitor(child, index, parent) {
var siblings = parent ? parent.children : []
var prev = index && siblings[index - 1]
if (
prev &&
child.type === prev.type &&
mergeable(prev, commonmark) &&
mergeable(child, commonmark)
) {
if (child.value) {
prev.value += child.value
}
if (child.children) {
prev.children = prev.children.concat(child.children)
}
siblings.splice(index, 1)
if (prev.position && child.position) {
prev.position.end = child.position.end
}
return index
}
}
}
function mergeable(node, commonmark) {
var start
var end
if (node.type === 'text') {
if (!node.position) {
return true
}
start = node.position.start
end = node.position.end
// Only merge nodes which occupy the same size as their `value`.
return (
start.line !== end.line || end.column - start.column === node.value.length
)
}
return commonmark && node.type === 'blockquote'
}

22
node_modules/mdast-util-compact/license generated vendored Normal file
View File

@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 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.

110
node_modules/mdast-util-compact/package.json generated vendored Normal file
View File

@ -0,0 +1,110 @@
{
"_from": "mdast-util-compact@^1.0.0",
"_id": "mdast-util-compact@1.0.3",
"_inBundle": false,
"_integrity": "sha512-nRiU5GpNy62rZppDKbLwhhtw5DXoFMqw9UNZFmlPsNaQCZ//WLjGKUwWMdJrUH+Se7UvtO2gXtAMe0g/N+eI5w==",
"_location": "/mdast-util-compact",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "mdast-util-compact@^1.0.0",
"name": "mdast-util-compact",
"escapedName": "mdast-util-compact",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/remark-stringify",
"/remark/remark-stringify"
],
"_resolved": "https://registry.npmjs.org/mdast-util-compact/-/mdast-util-compact-1.0.3.tgz",
"_shasum": "98a25cc8a7865761a41477b3a87d1dcef0b1e79d",
"_spec": "mdast-util-compact@^1.0.0",
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/remark/node_modules/remark-stringify",
"author": {
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "https://wooorm.com"
},
"bugs": {
"url": "https://github.com/syntax-tree/mdast-util-compact/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Titus Wormer",
"email": "tituswormer@gmail.com",
"url": "https://wooorm.com"
}
],
"dependencies": {
"unist-util-visit": "^1.1.0"
},
"deprecated": false,
"description": "Make an mdast tree compact",
"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",
"unist-builder": "^1.0.0",
"xo": "^0.24.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/syntax-tree/mdast-util-compact#readme",
"keywords": [
"mdast",
"utility",
"compact",
"node"
],
"license": "MIT",
"name": "mdast-util-compact",
"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/mdast-util-compact.git"
},
"scripts": {
"build": "npm run build-bundle && npm run build-mangle",
"build-bundle": "browserify . -s mdastUtilCompact > mdast-util-compact.js",
"build-mangle": "browserify . -s mdastUtilCompact -p tinyify > mdast-util-compact.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.0.3",
"xo": {
"prettier": true,
"esnext": false,
"ignores": [
"mdast-util-compact.js"
]
}
}

118
node_modules/mdast-util-compact/readme.md generated vendored Normal file
View File

@ -0,0 +1,118 @@
# mdast-util-compact
[![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 make trees compact: collapse text nodes (when
possible) and blockquotes (in commonmark mode).
## Install
[npm][]:
```sh
npm install mdast-util-compact
```
## Usage
```js
var u = require('unist-builder')
var compact = require('mdast-util-compact')
var tree = u('strong', [u('text', 'alpha'), u('text', ' '), u('text', 'bravo')])
compact(tree)
console.log(tree)
```
Yields:
```js
{ type: 'strong',
children: [ { type: 'text', value: 'alpha bravo' } ] }
```
## API
### `compact(tree[, commonmark])`
Walk the [tree][] and collapse nodes.
Combines adjacent [text][]s (but not when they represent entities or escapes).
If `commonmark` is `true`, collapses [blockquote][]s.
Handles [positional information][position-information] properly.
###### Returns
The given `tree`.
## 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-compact.svg
[build]: https://travis-ci.org/syntax-tree/mdast-util-compact
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-compact.svg
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-compact
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-compact.svg
[downloads]: https://www.npmjs.com/package/mdast-util-compact
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-compact.svg
[size]: https://bundlephobia.com/result?p=mdast-util-compact
[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
[mdast]: https://github.com/syntax-tree/mdast
[tree]: https://github.com/syntax-tree/unist#tree
[position-information]: https://github.com/syntax-tree/unist#positional-information
[text]: https://github.com/syntax-tree/mdast#text
[blockquote]: https://github.com/syntax-tree/mdast#blockquote