@adobe/helix-markdown-support 6.0.1 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +14 -1
- package/src/index.js +2 -0
- package/src/mdast-fix-root-phrasing.js +45 -0
- package/src/mdast-util-gfm-nolink.js +93 -0
- package/src/micromark-extension-gfm-nolink.js +112 -0
- package/src/remark-gfm-nolink.js +76 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [6.1.0](https://github.com/adobe/helix-markdown-support/compare/v6.0.2...v6.1.0) (2023-01-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add remark-gfm-nolink ([#167](https://github.com/adobe/helix-markdown-support/issues/167)) ([f10fa62](https://github.com/adobe/helix-markdown-support/commit/f10fa627d8a844c0d01a5727a01ecdea4177f36e))
|
|
7
|
+
|
|
8
|
+
## [6.0.2](https://github.com/adobe/helix-markdown-support/compare/v6.0.1...v6.0.2) (2023-01-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add root phrasing helper ([#166](https://github.com/adobe/helix-markdown-support/issues/166)) ([4a875b5](https://github.com/adobe/helix-markdown-support/commit/4a875b545e191ad7a10e749256c1955972c5a08e))
|
|
14
|
+
|
|
1
15
|
## [6.0.1](https://github.com/adobe/helix-markdown-support/compare/v6.0.0...v6.0.1) (2023-01-18)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-markdown-support",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Helix Markdown Support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -27,8 +27,19 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"hast-util-to-html": "8.0.4",
|
|
29
29
|
"js-yaml": "4.1.0",
|
|
30
|
+
"mdast-util-gfm-footnote": "1.0.1",
|
|
31
|
+
"mdast-util-gfm-strikethrough": "1.0.2",
|
|
32
|
+
"mdast-util-gfm-table": "1.0.6",
|
|
33
|
+
"mdast-util-gfm-task-list-item": "1.0.1",
|
|
34
|
+
"mdast-util-phrasing": "3.0.0",
|
|
30
35
|
"mdast-util-to-hast": "12.2.5",
|
|
36
|
+
"micromark-extension-gfm-footnote": "1.0.4",
|
|
37
|
+
"micromark-extension-gfm-strikethrough": "1.0.4",
|
|
38
|
+
"micromark-extension-gfm-table": "1.0.5",
|
|
39
|
+
"micromark-extension-gfm-tagfilter": "1.0.1",
|
|
40
|
+
"micromark-extension-gfm-task-list-item": "1.0.3",
|
|
31
41
|
"micromark-util-character": "1.1.0",
|
|
42
|
+
"micromark-util-combine-extensions": "1.0.0",
|
|
32
43
|
"micromark-util-symbol": "1.0.1",
|
|
33
44
|
"unist-util-find": "1.0.2",
|
|
34
45
|
"unist-util-visit": "4.1.1"
|
|
@@ -62,8 +73,10 @@
|
|
|
62
73
|
"mocha": "10.2.0",
|
|
63
74
|
"mocha-multi-reporters": "1.5.1",
|
|
64
75
|
"rehype-format": "4.0.1",
|
|
76
|
+
"rehype-stringify": "9.0.3",
|
|
65
77
|
"remark-gfm": "3.0.1",
|
|
66
78
|
"remark-parse": "10.0.1",
|
|
79
|
+
"remark-rehype": "10.1.0",
|
|
67
80
|
"remark-stringify": "10.0.2",
|
|
68
81
|
"semantic-release": "19.0.5",
|
|
69
82
|
"unified": "10.1.2",
|
package/src/index.js
CHANGED
|
@@ -16,8 +16,10 @@ export { default as sanitizeHeading } from './mdast-sanitize-heading.js';
|
|
|
16
16
|
export { default as suppressSpaceCode } from './mdast-suppress-spacecode.js';
|
|
17
17
|
export { default as sanitizeFormats } from './mdast-sanitize-formats.js';
|
|
18
18
|
export { default as fixCodeFlow } from './mdast-fix-code-flow.js';
|
|
19
|
+
export { default as fixRootPhrasing } from './mdast-fix-root-phrasing.js';
|
|
19
20
|
export { default as sanitizeLinks } from './mdast-sanitize-links.js';
|
|
20
21
|
export { default as sanitizeText } from './mdast-sanitize-text.js';
|
|
21
22
|
export { default as sanitizeTextAndFormats } from './mdast-sanitize-text-and-formats.js';
|
|
22
23
|
export { default as imageReferences } from './mdast-image-references.js';
|
|
23
24
|
export { default as dereference } from './mdast-dereference.js';
|
|
25
|
+
export { default as remarkGfmNoLink } from './remark-gfm-nolink.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { phrasing } from 'mdast-util-phrasing';
|
|
13
|
+
|
|
14
|
+
function wrap(children, from, to) {
|
|
15
|
+
const para = {
|
|
16
|
+
type: 'paragraph',
|
|
17
|
+
};
|
|
18
|
+
para.children = children.splice(from, to - from, para);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* ensures that the root node has no phrasing children.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} tree
|
|
25
|
+
* @returns {object} The modified (original) tree.
|
|
26
|
+
*/
|
|
27
|
+
export default function fixRootPhrasing(tree) {
|
|
28
|
+
const { children } = tree;
|
|
29
|
+
let firstPhrasing = -1;
|
|
30
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
31
|
+
if (phrasing(children[i])) {
|
|
32
|
+
if (firstPhrasing < 0) {
|
|
33
|
+
firstPhrasing = i;
|
|
34
|
+
}
|
|
35
|
+
} else if (firstPhrasing >= 0) {
|
|
36
|
+
wrap(children, firstPhrasing, i);
|
|
37
|
+
i = firstPhrasing;
|
|
38
|
+
firstPhrasing = -1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (firstPhrasing >= 0) {
|
|
42
|
+
wrap(children, firstPhrasing, children.length);
|
|
43
|
+
}
|
|
44
|
+
return tree;
|
|
45
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
copied from
|
|
15
|
+
https://github.com/micromark/micromark-extension-gfm/blob/7bc6b6f3baf941f877d7b2111e9257b21b13b37e/index.js
|
|
16
|
+
|
|
17
|
+
(The MIT License)
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
|
20
|
+
|
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
a copy of this software and associated documentation files (the
|
|
23
|
+
'Software'), to deal in the Software without restriction, including
|
|
24
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
the following conditions:
|
|
28
|
+
|
|
29
|
+
The above copyright notice and this permission notice shall be
|
|
30
|
+
included in all copies or substantial portions of the Software.
|
|
31
|
+
|
|
32
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
35
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
36
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
37
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
38
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension
|
|
43
|
+
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
|
|
44
|
+
*
|
|
45
|
+
* @typedef {import('mdast-util-gfm-table').Options} Options
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
// import {
|
|
49
|
+
// gfmAutolinkLiteralFromMarkdown,
|
|
50
|
+
// gfmAutolinkLiteralToMarkdown
|
|
51
|
+
// } from 'mdast-util-gfm-autolink-literal'
|
|
52
|
+
import {
|
|
53
|
+
gfmFootnoteFromMarkdown,
|
|
54
|
+
gfmFootnoteToMarkdown,
|
|
55
|
+
} from 'mdast-util-gfm-footnote';
|
|
56
|
+
import {
|
|
57
|
+
gfmStrikethroughFromMarkdown,
|
|
58
|
+
gfmStrikethroughToMarkdown,
|
|
59
|
+
} from 'mdast-util-gfm-strikethrough';
|
|
60
|
+
import { gfmTableFromMarkdown, gfmTableToMarkdown } from 'mdast-util-gfm-table';
|
|
61
|
+
import {
|
|
62
|
+
gfmTaskListItemFromMarkdown,
|
|
63
|
+
gfmTaskListItemToMarkdown,
|
|
64
|
+
} from 'mdast-util-gfm-task-list-item';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @returns {Array.<FromMarkdownExtension>}
|
|
68
|
+
*/
|
|
69
|
+
export function gfmFromMarkdown() {
|
|
70
|
+
return [
|
|
71
|
+
gfmFootnoteFromMarkdown(),
|
|
72
|
+
gfmStrikethroughFromMarkdown,
|
|
73
|
+
gfmTableFromMarkdown,
|
|
74
|
+
// gfmAutolinkLiteralFromMarkdown,
|
|
75
|
+
gfmTaskListItemFromMarkdown,
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {Options} [options]
|
|
81
|
+
* @returns {ToMarkdownExtension}
|
|
82
|
+
*/
|
|
83
|
+
export function gfmToMarkdown(options) {
|
|
84
|
+
return {
|
|
85
|
+
extensions: [
|
|
86
|
+
// gfmAutolinkLiteralToMarkdown,
|
|
87
|
+
gfmFootnoteToMarkdown(),
|
|
88
|
+
gfmStrikethroughToMarkdown,
|
|
89
|
+
gfmTableToMarkdown(options),
|
|
90
|
+
gfmTaskListItemToMarkdown,
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
copied from
|
|
15
|
+
https://github.com/micromark/micromark-extension-gfm/blob/942585eba9ec22fd9818638d42a7c8e62a7208b0/index.js
|
|
16
|
+
|
|
17
|
+
(The MIT License)
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
|
20
|
+
|
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
a copy of this software and associated documentation files (the
|
|
23
|
+
'Software'), to deal in the Software without restriction, including
|
|
24
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
the following conditions:
|
|
28
|
+
|
|
29
|
+
The above copyright notice and this permission notice shall be
|
|
30
|
+
included in all copies or substantial portions of the Software.
|
|
31
|
+
|
|
32
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
35
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
36
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
37
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
38
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {import('micromark-util-types').Extension} Extension
|
|
43
|
+
* @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension
|
|
44
|
+
* @typedef {import('micromark-extension-gfm-strikethrough').Options} Options
|
|
45
|
+
* @typedef {import('micromark-extension-gfm-footnote').HtmlOptions} HtmlOptions
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
import {
|
|
49
|
+
combineExtensions,
|
|
50
|
+
combineHtmlExtensions,
|
|
51
|
+
} from 'micromark-util-combine-extensions';
|
|
52
|
+
// import {
|
|
53
|
+
// gfmAutolinkLiteral,
|
|
54
|
+
// gfmAutolinkLiteralHtml,
|
|
55
|
+
// } from 'micromark-extension-gfm-autolink-literal';
|
|
56
|
+
import { gfmFootnote, gfmFootnoteHtml } from 'micromark-extension-gfm-footnote';
|
|
57
|
+
import {
|
|
58
|
+
gfmStrikethrough,
|
|
59
|
+
gfmStrikethroughHtml,
|
|
60
|
+
} from 'micromark-extension-gfm-strikethrough';
|
|
61
|
+
import { gfmTable, gfmTableHtml } from 'micromark-extension-gfm-table';
|
|
62
|
+
import { gfmTagfilterHtml } from 'micromark-extension-gfm-tagfilter';
|
|
63
|
+
import {
|
|
64
|
+
gfmTaskListItem,
|
|
65
|
+
gfmTaskListItemHtml,
|
|
66
|
+
} from 'micromark-extension-gfm-task-list-item';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Add support for parsing GFM in markdown.
|
|
70
|
+
*
|
|
71
|
+
* Function that can be called to get a syntax extension for micromark (passed
|
|
72
|
+
* in `extensions`).
|
|
73
|
+
*
|
|
74
|
+
* @param {Options} [options]
|
|
75
|
+
* Configuration (optional).
|
|
76
|
+
* Passed to `micromark-extens-gfm-strikethrough`.
|
|
77
|
+
* @returns {Extension}
|
|
78
|
+
* Syntax extension for micromark (passed in `extensions`).
|
|
79
|
+
*/
|
|
80
|
+
export function gfm(options) {
|
|
81
|
+
return combineExtensions([
|
|
82
|
+
// gfmAutolinkLiteral,
|
|
83
|
+
gfmFootnote(),
|
|
84
|
+
gfmStrikethrough(options),
|
|
85
|
+
gfmTable,
|
|
86
|
+
gfmTaskListItem,
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Add support for turning GFM in markdown to HTML.
|
|
92
|
+
*
|
|
93
|
+
* Function that can be called to get an HTML extension for micromark (passed
|
|
94
|
+
* in `htmlExtensions`).
|
|
95
|
+
*
|
|
96
|
+
* @param {HtmlOptions} [options]
|
|
97
|
+
* Configuration (optional).
|
|
98
|
+
* Passed to `micromark-extens-gfm-footnote`.
|
|
99
|
+
* @returns {HtmlExtension}
|
|
100
|
+
* HTML extension for micromark (passed in `htmlExtensions`).
|
|
101
|
+
*/
|
|
102
|
+
/* c8 ignore next 10 */
|
|
103
|
+
export function gfmHtml(options) {
|
|
104
|
+
return combineHtmlExtensions([
|
|
105
|
+
// gfmAutolinkLiteralHtml,
|
|
106
|
+
gfmFootnoteHtml(options),
|
|
107
|
+
gfmStrikethroughHtml,
|
|
108
|
+
gfmTableHtml,
|
|
109
|
+
gfmTagfilterHtml,
|
|
110
|
+
gfmTaskListItemHtml,
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
copied from
|
|
15
|
+
https://github.com/remarkjs/remark-gfm/blob/82542ee281b8aa1e113578a4a254717d0120fcb7/index.js
|
|
16
|
+
|
|
17
|
+
(The MIT License)
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
|
|
20
|
+
|
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
a copy of this software and associated documentation files (the
|
|
23
|
+
'Software'), to deal in the Software without restriction, including
|
|
24
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
the following conditions:
|
|
28
|
+
|
|
29
|
+
The above copyright notice and this permission notice shall be
|
|
30
|
+
included in all copies or substantial portions of the Software.
|
|
31
|
+
|
|
32
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
35
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
36
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
37
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
38
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/* eslint-disable no-unused-vars */
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {import('mdast').Root} Root
|
|
44
|
+
* @typedef {import('micromark-extension-gfm').Options & import('mdast-util-gfm').Options} Options
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
import { gfm } from './micromark-extension-gfm-nolink.js';
|
|
48
|
+
import { gfmFromMarkdown, gfmToMarkdown } from './mdast-util-gfm-nolink.js';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists).
|
|
52
|
+
*
|
|
53
|
+
* @this {import('unified').Processor}
|
|
54
|
+
* @type {import('unified').Plugin<[Options?]|void[], Root>}
|
|
55
|
+
*/
|
|
56
|
+
export default function remarkGfm(options = {}) {
|
|
57
|
+
const data = this.data();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {string} field
|
|
61
|
+
* @param {unknown} value
|
|
62
|
+
*/
|
|
63
|
+
function add(field, value) {
|
|
64
|
+
const list = /** @type {unknown[]} */ (
|
|
65
|
+
// Other extensions
|
|
66
|
+
/* c8 ignore next 2 */
|
|
67
|
+
data[field] ? data[field] : (data[field] = [])
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
list.push(value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
add('micromarkExtensions', gfm(options));
|
|
74
|
+
add('fromMarkdownExtensions', gfmFromMarkdown());
|
|
75
|
+
add('toMarkdownExtensions', gfmToMarkdown(options));
|
|
76
|
+
}
|