@putout/plugin-markdown 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) coderaiser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @putout/plugin-markdown [![NPM version][NPMIMGURL]][NPMURL]
2
+
3
+ [NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-markdown.svg?style=flat&longCache=true
4
+ [NPMURL]: https://npmjs.org/package/@putout/plugin-markdown "npm"
5
+
6
+ > Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents.
7
+ >
8
+ > (c) [markdownguide.org](https://www.markdownguide.org/getting-started/)
9
+
10
+ 🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to improve markdown.
11
+
12
+ ## Install
13
+
14
+ ```
15
+ npm i @putout/plugin-markdown -D
16
+ ```
17
+
18
+ ## Rules
19
+
20
+ - βœ… [merge-heading-spaces](#merge-heading-spaces);
21
+
22
+ ## Config
23
+
24
+ ```json
25
+ {
26
+ "rules": {
27
+ "markdown/merge-heading-spaces": "on"
28
+ }
29
+ }
30
+ ```
31
+
32
+ ### merge-heading-spaces
33
+
34
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f06796710b86267ac94715381e5d2217/8e05a45fe260926959ba4289c7d692b0597c94e1).
35
+
36
+ ## ❌ Example of incorrect code
37
+
38
+ ```markdown
39
+ # hello world
40
+ ```
41
+
42
+ ## βœ… Example of correct code
43
+
44
+ ```markdown
45
+ # hello world
46
+ ```
47
+
48
+ ## License
49
+
50
+ MIT
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import * as mergeHeadingSpaces from './merge-heading-spaces/index.js';
2
+
3
+ export const rules = {
4
+ 'merge-heading-spaces': mergeHeadingSpaces,
5
+ };
@@ -0,0 +1,8 @@
1
+ __putout_processor_markdown([
2
+ h1('Hello world'),
3
+ h2('Hello world'),
4
+ h3('Hello world'),
5
+ h4('Hello world'),
6
+ h5('Hello world'),
7
+ h6('Hello world'),
8
+ ]);
@@ -0,0 +1,8 @@
1
+ __putout_processor_markdown([
2
+ h1('Hello world'),
3
+ h2('Hello world'),
4
+ h3('Hello world'),
5
+ h4('Hello world'),
6
+ h5('Hello world'),
7
+ h6('Hello world'),
8
+ ]);
@@ -0,0 +1,38 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {
4
+ setLiteralValue,
5
+ __markdown,
6
+ traverse: superTraverse,
7
+ } = operator;
8
+
9
+ export const report = () => `Merge heading spaces`;
10
+
11
+ export const fix = (path) => {
12
+ const value = path.node.value.replace(' ', ' ');
13
+ setLiteralValue(path, value);
14
+ };
15
+ export const traverse = ({push}) => {
16
+ const merge = mergeHeadingSpace(push);
17
+
18
+ return {
19
+ [__markdown]: (path) => {
20
+ superTraverse(path, {
21
+ 'h1(__a)': merge,
22
+ 'h2(__a)': merge,
23
+ 'h3(__a)': merge,
24
+ 'h4(__a)': merge,
25
+ 'h5(__a)': merge,
26
+ 'h6(__a)': merge,
27
+ });
28
+ },
29
+ };
30
+ };
31
+
32
+ const mergeHeadingSpace = (push) => (path) => {
33
+ const arg = path.get('arguments.0');
34
+ const {value} = arg.node;
35
+
36
+ if (value.includes(' '))
37
+ push(arg);
38
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@putout/plugin-markdown",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
+ "description": "🐊Putout plugin adds ability to improve markdown",
7
+ "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-markdown#readme",
8
+ "main": "lib/markdown.js",
9
+ "release": false,
10
+ "tag": false,
11
+ "changelog": false,
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/coderaiser/putout.git"
15
+ },
16
+ "scripts": {
17
+ "test": "madrun test",
18
+ "watch:test": "madrun watch:test",
19
+ "lint": "madrun lint",
20
+ "fresh:lint": "madrun fresh:lint",
21
+ "lint:fresh": "madrun lint:fresh",
22
+ "fix:lint": "madrun fix:lint",
23
+ "coverage": "madrun coverage",
24
+ "report": "madrun report"
25
+ },
26
+ "dependencies": {},
27
+ "keywords": [
28
+ "putout",
29
+ "putout-plugin",
30
+ "putout-plugin-remove",
31
+ "plugin",
32
+ "debugger"
33
+ ],
34
+ "devDependencies": {
35
+ "@putout/test": "^15.0.0",
36
+ "eslint": "^10.0.0",
37
+ "eslint-plugin-putout": "^31.0.0",
38
+ "madrun": "^13.0.0",
39
+ "nodemon": "^3.0.1",
40
+ "redlint": "^6.0.0",
41
+ "superc8": "^12.0.0"
42
+ },
43
+ "peerDependencies": {
44
+ "putout": ">=42"
45
+ },
46
+ "license": "MIT",
47
+ "engines": {
48
+ "node": ">=22"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }