@putout/processor-markdown 7.0.2 → 7.3.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/README.md +1 -1
- package/lib/markdown.js +48 -7
- package/lib/rules/{index.mjs → index.js} +1 -14
- package/lib/rules/{merge-heading-spaces.mjs → merge-heading-spaces.js} +0 -0
- package/lib/rules/{remove-dependencies-status-badge.mjs → remove-dependencies-status-badge.js} +0 -0
- package/lib/rules/remove-dependencies-status-badge.md +2 -2
- package/lib/rules/{remove-trailing-whitespaces-from-heading.mjs → remove-trailing-whitespaces-from-heading.js} +0 -0
- package/package.json +13 -5
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
>
|
|
8
8
|
> (c) [markdownguide.org](https://www.markdownguide.org/)
|
|
9
9
|
|
|
10
|
-
🐊[**Putout**](https://github.com/coderaiser/putout) processor adds ability to get **JavaScript**, **JSON** and **TypeScript** code from
|
|
10
|
+
🐊[**Putout**](https://github.com/coderaiser/putout) processor adds ability to get **JavaScript**, **JSON** and **TypeScript** code from **Markdown** files.
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
package/lib/markdown.js
CHANGED
|
@@ -5,13 +5,22 @@ import {
|
|
|
5
5
|
import stringify from 'remark-stringify';
|
|
6
6
|
import preset from 'remark-preset-lint-consistent';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import removeDependenciesStatusBadge from './rules/remove-dependencies-status-badge.js';
|
|
9
|
+
import removeTrailingWhitespacesFromHeading from './rules/remove-trailing-whitespaces-from-heading.js';
|
|
10
|
+
import mergeHeadingSpceces from './rules/merge-heading-spaces.js';
|
|
11
|
+
import {run} from './rules/index.js';
|
|
9
12
|
import {visit} from 'unist-util-visit';
|
|
10
13
|
import {unified} from 'unified';
|
|
11
14
|
|
|
12
15
|
import {toPlace} from './parse-place.js';
|
|
13
16
|
import {initParseStore} from './parse-store.js';
|
|
14
17
|
|
|
18
|
+
const plugins = [
|
|
19
|
+
removeDependenciesStatusBadge,
|
|
20
|
+
removeTrailingWhitespacesFromHeading,
|
|
21
|
+
mergeHeadingSpceces,
|
|
22
|
+
];
|
|
23
|
+
|
|
15
24
|
const parseStore = initParseStore();
|
|
16
25
|
|
|
17
26
|
const text = ({value}) => value;
|
|
@@ -29,13 +38,19 @@ export const files = [
|
|
|
29
38
|
'*.md',
|
|
30
39
|
];
|
|
31
40
|
|
|
32
|
-
export const find = async (rawSource) => {
|
|
41
|
+
export const find = async (rawSource, options = {}) => {
|
|
33
42
|
await parseStore.init();
|
|
34
43
|
|
|
35
44
|
const {messages} = await unified()
|
|
36
45
|
.use(parseStore)
|
|
37
46
|
.use(preset)
|
|
38
|
-
.use(run, {
|
|
47
|
+
.use(run, {
|
|
48
|
+
fix: false,
|
|
49
|
+
plugins: [
|
|
50
|
+
...plugins,
|
|
51
|
+
...options.plugins || [],
|
|
52
|
+
],
|
|
53
|
+
})
|
|
39
54
|
.use(stringify, stringifyOptions)
|
|
40
55
|
.process(rawSource);
|
|
41
56
|
|
|
@@ -43,13 +58,19 @@ export const find = async (rawSource) => {
|
|
|
43
58
|
.map(toPlace);
|
|
44
59
|
};
|
|
45
60
|
|
|
46
|
-
export const fix = async (rawSource) => {
|
|
61
|
+
export const fix = async (rawSource, options = {}) => {
|
|
47
62
|
await parseStore.init();
|
|
48
63
|
|
|
49
64
|
const {value} = await unified()
|
|
50
65
|
.use(parseStore)
|
|
51
66
|
.use(preset)
|
|
52
|
-
.use(run, {
|
|
67
|
+
.use(run, {
|
|
68
|
+
fix: true,
|
|
69
|
+
plugins: [
|
|
70
|
+
...plugins,
|
|
71
|
+
...options.plugins || [],
|
|
72
|
+
],
|
|
73
|
+
})
|
|
53
74
|
.use(stringify, stringifyOptions)
|
|
54
75
|
.process(rawSource);
|
|
55
76
|
|
|
@@ -104,6 +125,16 @@ const collect = ({list, visit}) => (node) => {
|
|
|
104
125
|
return;
|
|
105
126
|
}
|
|
106
127
|
|
|
128
|
+
if (lang === 'jsx') {
|
|
129
|
+
list.push({
|
|
130
|
+
startLine,
|
|
131
|
+
source: value,
|
|
132
|
+
extension: 'jsx',
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
107
138
|
if (/^(ts|typescript)$/.test(lang)) {
|
|
108
139
|
list.push({
|
|
109
140
|
startLine,
|
|
@@ -114,6 +145,16 @@ const collect = ({list, visit}) => (node) => {
|
|
|
114
145
|
return;
|
|
115
146
|
}
|
|
116
147
|
|
|
148
|
+
if (lang === 'tsx') {
|
|
149
|
+
list.push({
|
|
150
|
+
startLine,
|
|
151
|
+
source: value,
|
|
152
|
+
extension: 'tsx',
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
117
158
|
if (lang === 'json') {
|
|
118
159
|
const source = toJS(value);
|
|
119
160
|
|
|
@@ -130,12 +171,12 @@ const apply = ({list, visit}) => (node) => {
|
|
|
130
171
|
visit(node, 'code', (node) => {
|
|
131
172
|
const {lang} = node;
|
|
132
173
|
|
|
133
|
-
if (/^(
|
|
174
|
+
if (/^(jsx?|javascript)$/.test(lang)) {
|
|
134
175
|
node.value = list.shift();
|
|
135
176
|
return;
|
|
136
177
|
}
|
|
137
178
|
|
|
138
|
-
if (/^(
|
|
179
|
+
if (/^(tsx?|typescript)$/.test(lang)) {
|
|
139
180
|
node.value = list.shift();
|
|
140
181
|
return;
|
|
141
182
|
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import {lintRule} from 'unified-lint-rule';
|
|
2
|
-
import removeDependenciesStatusBadge from './remove-dependencies-status-badge.mjs';
|
|
3
|
-
import removeTrailingWhitespacesFromHeading from './remove-trailing-whitespaces-from-heading.mjs';
|
|
4
|
-
import mergeHeadingSpceces from './merge-heading-spaces.mjs';
|
|
5
|
-
|
|
6
|
-
const plugins = [
|
|
7
|
-
removeDependenciesStatusBadge,
|
|
8
|
-
removeTrailingWhitespacesFromHeading,
|
|
9
|
-
mergeHeadingSpceces,
|
|
10
|
-
];
|
|
11
2
|
|
|
12
3
|
export const run = lintRule('remark-lint:run', (tree, file, options) => {
|
|
13
|
-
for (const {fix, traverse, report, name} of plugins) {
|
|
4
|
+
for (const {fix, traverse, report, name} of options.plugins) {
|
|
14
5
|
const nodes = [];
|
|
15
6
|
const push = nodes.push.bind(nodes);
|
|
16
7
|
|
|
@@ -30,7 +21,3 @@ export const run = lintRule('remark-lint:run', (tree, file, options) => {
|
|
|
30
21
|
}
|
|
31
22
|
});
|
|
32
23
|
|
|
33
|
-
export const rules = {
|
|
34
|
-
plugins,
|
|
35
|
-
};
|
|
36
|
-
|
|
File without changes
|
package/lib/rules/{remove-dependencies-status-badge.mjs → remove-dependencies-status-badge.js}
RENAMED
|
File without changes
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
## Rule Details
|
|
4
4
|
|
|
5
5
|
```diff
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
-# @putout/plugin-apply-replace-all [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]
|
|
7
|
+
+# @putout/plugin-apply-replace-all [![NPM version][NPMIMGURL]][NPMURL]
|
|
8
8
|
|
|
9
9
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-apply-replace-all.svg?style=flat&longCache=true
|
|
10
10
|
[NPMURL]: https://npmjs.org/package/@putout/plugin-apply-replace-all "npm"
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/processor-markdown",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout processor adds ability to parse markdown files and lint js snippets",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/processor-markdown#readme",
|
|
8
|
-
"main": "lib/markdown.js",
|
|
8
|
+
"main": "./lib/markdown.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./lib/markdown.js",
|
|
11
|
+
"./parse-store": "./lib/parse-store.js"
|
|
12
|
+
},
|
|
9
13
|
"release": false,
|
|
10
14
|
"tag": false,
|
|
11
15
|
"changelog": false,
|
|
@@ -21,6 +25,7 @@
|
|
|
21
25
|
"lint:fresh": "madrun lint:fresh",
|
|
22
26
|
"fix:lint": "madrun fix:lint",
|
|
23
27
|
"coverage": "madrun coverage",
|
|
28
|
+
"coverage:old": "madrun coverage:old",
|
|
24
29
|
"report": "madrun report"
|
|
25
30
|
},
|
|
26
31
|
"dependencies": {
|
|
@@ -41,11 +46,14 @@
|
|
|
41
46
|
"devDependencies": {
|
|
42
47
|
"@putout/test": "^5.0.0",
|
|
43
48
|
"c8": "^7.5.0",
|
|
49
|
+
"escover": "^2.1.2",
|
|
44
50
|
"eslint": "^8.0.1",
|
|
45
|
-
"eslint-plugin-
|
|
46
|
-
"eslint-plugin-putout": "^
|
|
47
|
-
"lerna": "^
|
|
51
|
+
"eslint-plugin-n": "^15.2.4",
|
|
52
|
+
"eslint-plugin-putout": "^16.0.0",
|
|
53
|
+
"lerna": "^5.0.0",
|
|
54
|
+
"madcut": "^1.0.0",
|
|
48
55
|
"madrun": "^9.0.0",
|
|
56
|
+
"montag": "^1.2.1",
|
|
49
57
|
"nodemon": "^2.0.1",
|
|
50
58
|
"putout": "*",
|
|
51
59
|
"supertape": "^7.0.0"
|