This commit is contained in:
42
node_modules/mdast-util-gfm/from-markdown.js
generated
vendored
Normal file
42
node_modules/mdast-util-gfm/from-markdown.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
var autolinkLiteral = require('mdast-util-gfm-autolink-literal/from-markdown')
|
||||
var strikethrough = require('mdast-util-gfm-strikethrough/from-markdown')
|
||||
var table = require('mdast-util-gfm-table/from-markdown')
|
||||
var taskListItem = require('mdast-util-gfm-task-list-item/from-markdown')
|
||||
|
||||
var own = {}.hasOwnProperty
|
||||
|
||||
module.exports = configure([
|
||||
autolinkLiteral,
|
||||
strikethrough,
|
||||
table,
|
||||
taskListItem
|
||||
])
|
||||
|
||||
function configure(extensions) {
|
||||
var config = {transforms: [], canContainEols: []}
|
||||
var length = extensions.length
|
||||
var index = -1
|
||||
|
||||
while (++index < length) {
|
||||
extension(config, extensions[index])
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
function extension(config, extension) {
|
||||
var key
|
||||
var left
|
||||
var right
|
||||
|
||||
for (key in extension) {
|
||||
left = own.call(config, key) ? config[key] : (config[key] = {})
|
||||
right = extension[key]
|
||||
|
||||
if (key === 'canContainEols' || key === 'transforms') {
|
||||
config[key] = [].concat(left, right)
|
||||
} else {
|
||||
Object.assign(left, right)
|
||||
}
|
||||
}
|
||||
}
|
||||
2
node_modules/mdast-util-gfm/index.js
generated
vendored
Normal file
2
node_modules/mdast-util-gfm/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
exports.fromMarkdown = require('./from-markdown')
|
||||
exports.toMarkdown = require('./to-markdown')
|
||||
22
node_modules/mdast-util-gfm/license
generated
vendored
Normal file
22
node_modules/mdast-util-gfm/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2020 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.
|
||||
93
node_modules/mdast-util-gfm/package.json
generated
vendored
Normal file
93
node_modules/mdast-util-gfm/package.json
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"name": "mdast-util-gfm",
|
||||
"version": "0.1.2",
|
||||
"description": "mdast extension to parse and serialize GFM (GitHub Flavored Markdown)",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"mdast",
|
||||
"mdast-util",
|
||||
"util",
|
||||
"utility",
|
||||
"markdown",
|
||||
"markup",
|
||||
"table",
|
||||
"strikethrough",
|
||||
"tasklist",
|
||||
"autolink",
|
||||
"tagfilter",
|
||||
"github",
|
||||
"gfm",
|
||||
"gfm"
|
||||
],
|
||||
"repository": "syntax-tree/mdast-util-gfm",
|
||||
"bugs": "https://github.com/syntax-tree/mdast-util-gfm/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": [
|
||||
"from-markdown.js",
|
||||
"index.js",
|
||||
"to-markdown.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-gfm-autolink-literal": "^0.1.0",
|
||||
"mdast-util-gfm-strikethrough": "^0.2.0",
|
||||
"mdast-util-gfm-table": "^0.1.0",
|
||||
"mdast-util-gfm-task-list-item": "^0.1.0",
|
||||
"mdast-util-to-markdown": "^0.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"github-slugger": "^1.0.0",
|
||||
"hast-util-to-html": "^7.0.0",
|
||||
"mdast-util-from-markdown": "^0.8.0",
|
||||
"mdast-util-to-hast": "^10.0.0",
|
||||
"micromark-extension-gfm": "^0.3.0",
|
||||
"node-fetch": "^2.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",
|
||||
"xo": "^0.37.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"crawl": "node script/crawl-tests",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test/index.js",
|
||||
"test": "npm run format && 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,
|
||||
"rules": {
|
||||
"guard-for-in": "off",
|
||||
"unicorn/prefer-optional-catch-binding": "off"
|
||||
}
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
320
node_modules/mdast-util-gfm/readme.md
generated
vendored
Normal file
320
node_modules/mdast-util-gfm/readme.md
generated
vendored
Normal file
@@ -0,0 +1,320 @@
|
||||
# mdast-util-gfm
|
||||
|
||||
[![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]
|
||||
|
||||
Extension for [`mdast-util-from-markdown`][from-markdown] and/or
|
||||
[`mdast-util-to-markdown`][to-markdown] to support GitHub flavored markdown in
|
||||
**[mdast][]**.
|
||||
When parsing (`from-markdown`), must be combined with
|
||||
[`micromark-extension-gfm`][extension].
|
||||
|
||||
You probably shouldn’t use this package directly, but instead use
|
||||
[`remark-gfm`][remark-gfm] with **[remark][]**.
|
||||
|
||||
Alternatively, the extensions can be used separately:
|
||||
|
||||
* [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)
|
||||
— support GFM autolink literals
|
||||
* [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)
|
||||
— support GFM strikethrough
|
||||
* [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)
|
||||
— support GFM tables
|
||||
* [`syntax-tree/mdast-util-gfm-task-list-item`](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)
|
||||
— support GFM tasklists
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install mdast-util-gfm
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
Say we have the following file, `example.md`:
|
||||
|
||||
```markdown
|
||||
# GFM
|
||||
|
||||
## Autolink literals
|
||||
|
||||
www.example.com, https://example.com, and contact@example.com.
|
||||
|
||||
## Strikethrough
|
||||
|
||||
~one~ or ~~two~~ tildes.
|
||||
|
||||
## Table
|
||||
|
||||
| a | b | c | d |
|
||||
| - | :- | -: | :-: |
|
||||
|
||||
## Tasklist
|
||||
|
||||
* [ ] to do
|
||||
* [x] done
|
||||
```
|
||||
|
||||
And our script, `example.js`, looks as follows:
|
||||
|
||||
```js
|
||||
var fs = require('fs')
|
||||
var fromMarkdown = require('mdast-util-from-markdown')
|
||||
var toMarkdown = require('mdast-util-to-markdown')
|
||||
var syntax = require('micromark-extension-gfm')
|
||||
var gfm = require('mdast-util-gfm')
|
||||
|
||||
var doc = fs.readFileSync('example.md')
|
||||
|
||||
var tree = fromMarkdown(doc, {
|
||||
extensions: [syntax()],
|
||||
mdastExtensions: [gfm.fromMarkdown]
|
||||
})
|
||||
|
||||
console.log(tree)
|
||||
|
||||
var out = toMarkdown(tree, {extensions: [gfm.toMarkdown()]})
|
||||
|
||||
console.log(out)
|
||||
```
|
||||
|
||||
Now, running `node example` yields:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'root',
|
||||
children: [
|
||||
{type: 'heading', depth: 1, children: [{type: 'text', value: 'GFM'}]},
|
||||
{
|
||||
type: 'heading',
|
||||
depth: 2,
|
||||
children: [{type: 'text', value: 'Autolink literals'}]
|
||||
},
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{
|
||||
type: 'link',
|
||||
title: null,
|
||||
url: 'http://www.example.com',
|
||||
children: [{type: 'text', value: 'www.example.com'}]
|
||||
},
|
||||
{type: 'text', value: ', '},
|
||||
{
|
||||
type: 'link',
|
||||
title: null,
|
||||
url: 'https://example.com',
|
||||
children: [{type: 'text', value: 'https://example.com'}]
|
||||
},
|
||||
{type: 'text', value: ', and '},
|
||||
{
|
||||
type: 'link',
|
||||
title: null,
|
||||
url: 'mailto:contact@example.com',
|
||||
children: [{type: 'text', value: 'contact@example.com'}]
|
||||
},
|
||||
{type: 'text', value: '.'}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'heading',
|
||||
depth: 2,
|
||||
children: [{type: 'text', value: 'Strikethrough'}]
|
||||
},
|
||||
{
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
{
|
||||
type: 'delete',
|
||||
children: [{type: 'text', value: 'one'}]
|
||||
},
|
||||
{type: 'text', value: ' or '},
|
||||
{
|
||||
type: 'delete',
|
||||
children: [{type: 'text', value: 'two'}]
|
||||
},
|
||||
{type: 'text', value: ' tildes.'}
|
||||
]
|
||||
},
|
||||
{type: 'heading', depth: 2, children: [{type: 'text', value: 'Table'}]},
|
||||
{
|
||||
type: 'table',
|
||||
align: [null, 'left', 'right', 'center'],
|
||||
children: [
|
||||
{
|
||||
type: 'tableRow',
|
||||
children: [
|
||||
{type: 'tableCell', children: [{type: 'text', value: 'a'}]},
|
||||
{type: 'tableCell', children: [{type: 'text', value: 'b'}]},
|
||||
{type: 'tableCell', children: [{type: 'text', value: 'c'}]},
|
||||
{type: 'tableCell', children: [{type: 'text', value: 'd'}]}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{type: 'heading', depth: 2, children: [{type: 'text', value: 'Tasklist'}]},
|
||||
{
|
||||
type: 'list',
|
||||
ordered: false,
|
||||
start: null,
|
||||
spread: false,
|
||||
children: [
|
||||
{
|
||||
type: 'listItem',
|
||||
spread: false,
|
||||
checked: false,
|
||||
children: [
|
||||
{type: 'paragraph', children: [{type: 'text', value: 'to do'}]}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'listItem',
|
||||
spread: false,
|
||||
checked: true,
|
||||
children: [
|
||||
{type: 'paragraph', children: [{type: 'text', value: 'done'}]}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```markdown
|
||||
# GFM
|
||||
|
||||
## Autolink literals
|
||||
|
||||
[www.example.com](http://www.example.com), <https://example.com>, and <contact@example.com>.
|
||||
|
||||
## Strikethrough
|
||||
|
||||
~~one~~ or ~~two~~ tildes.
|
||||
|
||||
## Table
|
||||
|
||||
| a | b | c | d |
|
||||
| - | :- | -: | :-: |
|
||||
|
||||
## Tasklist
|
||||
|
||||
* [ ] to do
|
||||
* [x] done
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `gfm.fromMarkdown`
|
||||
|
||||
### `gfm.toMarkdown(options?)`
|
||||
|
||||
> Note: the separate extensions are also available at
|
||||
> `mdast-util-gfm/from-markdown` and
|
||||
> `mdast-util-gfm/to-markdown`.
|
||||
|
||||
Support GFM.
|
||||
The exports of `fromMarkdown` is an extension for
|
||||
[`mdast-util-from-markdown`][from-markdown].
|
||||
The export of `toMarkdown` is a function that can be called with options and
|
||||
returns an extension for [`mdast-util-to-markdown`][to-markdown].
|
||||
|
||||
###### `options`
|
||||
|
||||
Passed as `options` to [`mdast-util-gfm-table`][table].
|
||||
|
||||
The exports are extensions, respectively
|
||||
for [`mdast-util-from-markdown`][from-markdown] and
|
||||
[`mdast-util-to-markdown`][to-markdown].
|
||||
|
||||
## Related
|
||||
|
||||
* [`remarkjs/remark`][remark]
|
||||
— markdown processor powered by plugins
|
||||
* [`remarkjs/remark-gfm`][remark-gfm]
|
||||
— remark plugin to support GFM
|
||||
* [`micromark/micromark`][micromark]
|
||||
— the smallest commonmark-compliant markdown parser that exists
|
||||
* [`micromark/micromark-extension-gfm`][extension]
|
||||
— micromark extension to parse GFM
|
||||
* [`syntax-tree/mdast-util-from-markdown`][from-markdown]
|
||||
— mdast parser using `micromark` to create mdast from markdown
|
||||
* [`syntax-tree/mdast-util-to-markdown`][to-markdown]
|
||||
— mdast serializer to create markdown from mdast
|
||||
|
||||
## 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-gfm/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/syntax-tree/mdast-util-gfm/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-gfm.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/mdast-util-gfm
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-gfm.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/mdast-util-gfm
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-gfm.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=mdast-util-gfm
|
||||
|
||||
[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
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[remark-gfm]: https://github.com/remarkjs/remark-gfm
|
||||
|
||||
[from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown
|
||||
|
||||
[to-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown
|
||||
|
||||
[micromark]: https://github.com/micromark/micromark
|
||||
|
||||
[extension]: https://github.com/micromark/micromark-extension-gfm
|
||||
|
||||
[table]: https://github.com/syntax-tree/mdast-util-gfm-table#options
|
||||
22
node_modules/mdast-util-gfm/to-markdown.js
generated
vendored
Normal file
22
node_modules/mdast-util-gfm/to-markdown.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var autolinkLiteral = require('mdast-util-gfm-autolink-literal/to-markdown')
|
||||
var strikethrough = require('mdast-util-gfm-strikethrough/to-markdown')
|
||||
var table = require('mdast-util-gfm-table/to-markdown')
|
||||
var taskListItem = require('mdast-util-gfm-task-list-item/to-markdown')
|
||||
var configure = require('mdast-util-to-markdown/lib/configure')
|
||||
|
||||
module.exports = toMarkdown
|
||||
|
||||
function toMarkdown(options) {
|
||||
var config = configure(
|
||||
{handlers: {}, join: [], unsafe: [], options: {}},
|
||||
{
|
||||
extensions: [autolinkLiteral, strikethrough, table(options), taskListItem]
|
||||
}
|
||||
)
|
||||
|
||||
return Object.assign(config.options, {
|
||||
handlers: config.handlers,
|
||||
join: config.join,
|
||||
unsafe: config.unsafe
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user