@putout/processor-markdown 7.2.0 → 8.0.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 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 markdown files.
10
+ 🐊[**Putout**](https://github.com/coderaiser/putout) processor adds ability to get **JavaScript**, **JSX**, **JSON** and **TypeScript** code from **Markdown** files.
11
11
 
12
12
  ## Install
13
13
 
package/lib/markdown.js CHANGED
@@ -8,13 +8,6 @@ import preset from 'remark-preset-lint-consistent';
8
8
  import removeDependenciesStatusBadge from './rules/remove-dependencies-status-badge.js';
9
9
  import removeTrailingWhitespacesFromHeading from './rules/remove-trailing-whitespaces-from-heading.js';
10
10
  import mergeHeadingSpceces from './rules/merge-heading-spaces.js';
11
-
12
- const plugins = [
13
- removeDependenciesStatusBadge,
14
- removeTrailingWhitespacesFromHeading,
15
- mergeHeadingSpceces,
16
- ];
17
-
18
11
  import {run} from './rules/index.js';
19
12
  import {visit} from 'unist-util-visit';
20
13
  import {unified} from 'unified';
@@ -22,6 +15,12 @@ import {unified} from 'unified';
22
15
  import {toPlace} from './parse-place.js';
23
16
  import {initParseStore} from './parse-store.js';
24
17
 
18
+ const plugins = [
19
+ removeDependenciesStatusBadge,
20
+ removeTrailingWhitespacesFromHeading,
21
+ mergeHeadingSpceces,
22
+ ];
23
+
25
24
  const parseStore = initParseStore();
26
25
 
27
26
  const text = ({value}) => value;
@@ -39,13 +38,22 @@ export const files = [
39
38
  '*.md',
40
39
  ];
41
40
 
42
- export const find = async (rawSource) => {
41
+ export const find = async (rawSource, options = {}) => {
42
+ if (!rawSource.length)
43
+ return [];
44
+
43
45
  await parseStore.init();
44
46
 
45
47
  const {messages} = await unified()
46
48
  .use(parseStore)
47
49
  .use(preset)
48
- .use(run, {plugins, fix: false})
50
+ .use(run, {
51
+ fix: false,
52
+ plugins: [
53
+ ...plugins,
54
+ ...options.plugins || [],
55
+ ],
56
+ })
49
57
  .use(stringify, stringifyOptions)
50
58
  .process(rawSource);
51
59
 
@@ -53,13 +61,19 @@ export const find = async (rawSource) => {
53
61
  .map(toPlace);
54
62
  };
55
63
 
56
- export const fix = async (rawSource) => {
64
+ export const fix = async (rawSource, options = {}) => {
57
65
  await parseStore.init();
58
66
 
59
67
  const {value} = await unified()
60
68
  .use(parseStore)
61
69
  .use(preset)
62
- .use(run, {plugins, fix: true})
70
+ .use(run, {
71
+ fix: true,
72
+ plugins: [
73
+ ...plugins,
74
+ ...options.plugins || [],
75
+ ],
76
+ })
63
77
  .use(stringify, stringifyOptions)
64
78
  .process(rawSource);
65
79
 
@@ -3,8 +3,8 @@
3
3
  ## Rule Details
4
4
 
5
5
  ```diff
6
- # @putout/plugin-apply-replace-all [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]
7
- --# @putout/plugin-apply-replace-all [![NPM version][NPMIMGURL]][NPMURL]
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"
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@putout/processor-markdown",
3
- "version": "7.2.0",
3
+ "version": "8.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
- "description": "🐊Putout processor adds ability to parse markdown files and lint js snippets",
6
+ "description": "🐊Putout processor adds ability to parse markdown files and lint JavaScript, JSX, TypeScript and JSON 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
+ "commitType": "colon",
10
+ "exports": {
11
+ ".": "./lib/markdown.js",
12
+ "./parse-store": "./lib/parse-store.js"
13
+ },
9
14
  "release": false,
10
15
  "tag": false,
11
16
  "changelog": false,
@@ -44,16 +49,18 @@
44
49
  "c8": "^7.5.0",
45
50
  "escover": "^2.1.2",
46
51
  "eslint": "^8.0.1",
47
- "eslint-plugin-node": "^11.0.0",
48
- "eslint-plugin-putout": "^15.0.0",
49
- "lerna": "^4.0.0",
52
+ "eslint-plugin-n": "^15.2.4",
53
+ "eslint-plugin-putout": "^16.0.0",
54
+ "lerna": "^6.0.1",
55
+ "madcut": "^1.0.0",
50
56
  "madrun": "^9.0.0",
57
+ "montag": "^1.2.1",
51
58
  "nodemon": "^2.0.1",
52
59
  "putout": "*",
53
- "supertape": "^7.0.0"
60
+ "supertape": "^8.0.0"
54
61
  },
55
62
  "peerDependencies": {
56
- "putout": ">=26"
63
+ "putout": ">=28"
57
64
  },
58
65
  "engines": {
59
66
  "node": ">=16"