@dougis/markdown-lint-mcp 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/CHANGELOG.md +80 -0
- package/CONTRIBUTING.md +474 -0
- package/LICENSE +21 -0
- package/README.md +240 -0
- package/USAGE.md +40 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/index.d.ts +22 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +144 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/md001.d.ts +25 -0
- package/dist/rules/md001.d.ts.map +1 -0
- package/dist/rules/md001.js +79 -0
- package/dist/rules/md001.js.map +1 -0
- package/dist/rules/md003.d.ts +41 -0
- package/dist/rules/md003.d.ts.map +1 -0
- package/dist/rules/md003.js +130 -0
- package/dist/rules/md003.js.map +1 -0
- package/dist/rules/md004.d.ts +28 -0
- package/dist/rules/md004.d.ts.map +1 -0
- package/dist/rules/md004.js +79 -0
- package/dist/rules/md004.js.map +1 -0
- package/dist/rules/md005.d.ts +21 -0
- package/dist/rules/md005.d.ts.map +1 -0
- package/dist/rules/md005.js +88 -0
- package/dist/rules/md005.js.map +1 -0
- package/dist/rules/md007.d.ts +21 -0
- package/dist/rules/md007.d.ts.map +1 -0
- package/dist/rules/md007.js +66 -0
- package/dist/rules/md007.js.map +1 -0
- package/dist/rules/md009.d.ts +35 -0
- package/dist/rules/md009.d.ts.map +1 -0
- package/dist/rules/md009.js +122 -0
- package/dist/rules/md009.js.map +1 -0
- package/dist/rules/md010.d.ts +34 -0
- package/dist/rules/md010.d.ts.map +1 -0
- package/dist/rules/md010.js +75 -0
- package/dist/rules/md010.js.map +1 -0
- package/dist/rules/md011.d.ts +30 -0
- package/dist/rules/md011.d.ts.map +1 -0
- package/dist/rules/md011.js +123 -0
- package/dist/rules/md011.js.map +1 -0
- package/dist/rules/md012.d.ts +33 -0
- package/dist/rules/md012.d.ts.map +1 -0
- package/dist/rules/md012.js +125 -0
- package/dist/rules/md012.js.map +1 -0
- package/dist/rules/md013.d.ts +26 -0
- package/dist/rules/md013.d.ts.map +1 -0
- package/dist/rules/md013.js +32 -0
- package/dist/rules/md013.js.map +1 -0
- package/dist/rules/md014.d.ts +29 -0
- package/dist/rules/md014.d.ts.map +1 -0
- package/dist/rules/md014.js +176 -0
- package/dist/rules/md014.js.map +1 -0
- package/dist/rules/md018.d.ts +22 -0
- package/dist/rules/md018.d.ts.map +1 -0
- package/dist/rules/md018.js +27 -0
- package/dist/rules/md018.js.map +1 -0
- package/dist/rules/md019.d.ts +22 -0
- package/dist/rules/md019.d.ts.map +1 -0
- package/dist/rules/md019.js +27 -0
- package/dist/rules/md019.js.map +1 -0
- package/dist/rules/md020.d.ts +22 -0
- package/dist/rules/md020.d.ts.map +1 -0
- package/dist/rules/md020.js +27 -0
- package/dist/rules/md020.js.map +1 -0
- package/dist/rules/md021.d.ts +22 -0
- package/dist/rules/md021.d.ts.map +1 -0
- package/dist/rules/md021.js +27 -0
- package/dist/rules/md021.js.map +1 -0
- package/dist/rules/md022.d.ts +21 -0
- package/dist/rules/md022.d.ts.map +1 -0
- package/dist/rules/md022.js +43 -0
- package/dist/rules/md022.js.map +1 -0
- package/dist/rules/md023.d.ts +21 -0
- package/dist/rules/md023.d.ts.map +1 -0
- package/dist/rules/md023.js +34 -0
- package/dist/rules/md023.js.map +1 -0
- package/dist/rules/md024.d.ts +30 -0
- package/dist/rules/md024.d.ts.map +1 -0
- package/dist/rules/md024.js +123 -0
- package/dist/rules/md024.js.map +1 -0
- package/dist/rules/md025.d.ts +34 -0
- package/dist/rules/md025.d.ts.map +1 -0
- package/dist/rules/md025.js +134 -0
- package/dist/rules/md025.js.map +1 -0
- package/dist/rules/md026.d.ts +21 -0
- package/dist/rules/md026.d.ts.map +1 -0
- package/dist/rules/md026.js +31 -0
- package/dist/rules/md026.js.map +1 -0
- package/dist/rules/md027.d.ts +22 -0
- package/dist/rules/md027.d.ts.map +1 -0
- package/dist/rules/md027.js +27 -0
- package/dist/rules/md027.js.map +1 -0
- package/dist/rules/md028.d.ts +37 -0
- package/dist/rules/md028.d.ts.map +1 -0
- package/dist/rules/md028.js +84 -0
- package/dist/rules/md028.js.map +1 -0
- package/dist/rules/md029.d.ts +30 -0
- package/dist/rules/md029.d.ts.map +1 -0
- package/dist/rules/md029.js +36 -0
- package/dist/rules/md029.js.map +1 -0
- package/dist/rules/md030.d.ts +28 -0
- package/dist/rules/md030.d.ts.map +1 -0
- package/dist/rules/md030.js +76 -0
- package/dist/rules/md030.js.map +1 -0
- package/dist/rules/md031.d.ts +22 -0
- package/dist/rules/md031.d.ts.map +1 -0
- package/dist/rules/md031.js +55 -0
- package/dist/rules/md031.js.map +1 -0
- package/dist/rules/md032.d.ts +21 -0
- package/dist/rules/md032.d.ts.map +1 -0
- package/dist/rules/md032.js +69 -0
- package/dist/rules/md032.js.map +1 -0
- package/dist/rules/md033.d.ts +28 -0
- package/dist/rules/md033.d.ts.map +1 -0
- package/dist/rules/md033.js +34 -0
- package/dist/rules/md033.js.map +1 -0
- package/dist/rules/md034.d.ts +28 -0
- package/dist/rules/md034.d.ts.map +1 -0
- package/dist/rules/md034.js +100 -0
- package/dist/rules/md034.js.map +1 -0
- package/dist/rules/md035.d.ts +23 -0
- package/dist/rules/md035.d.ts.map +1 -0
- package/dist/rules/md035.js +52 -0
- package/dist/rules/md035.js.map +1 -0
- package/dist/rules/md036.d.ts +34 -0
- package/dist/rules/md036.d.ts.map +1 -0
- package/dist/rules/md036.js +112 -0
- package/dist/rules/md036.js.map +1 -0
- package/dist/rules/md037.d.ts +28 -0
- package/dist/rules/md037.d.ts.map +1 -0
- package/dist/rules/md037.js +122 -0
- package/dist/rules/md037.js.map +1 -0
- package/dist/rules/md038.d.ts +28 -0
- package/dist/rules/md038.d.ts.map +1 -0
- package/dist/rules/md038.js +62 -0
- package/dist/rules/md038.js.map +1 -0
- package/dist/rules/md039.d.ts +21 -0
- package/dist/rules/md039.d.ts.map +1 -0
- package/dist/rules/md039.js +34 -0
- package/dist/rules/md039.js.map +1 -0
- package/dist/rules/md040.d.ts +21 -0
- package/dist/rules/md040.d.ts.map +1 -0
- package/dist/rules/md040.js +46 -0
- package/dist/rules/md040.js.map +1 -0
- package/dist/rules/md041.d.ts +33 -0
- package/dist/rules/md041.d.ts.map +1 -0
- package/dist/rules/md041.js +92 -0
- package/dist/rules/md041.js.map +1 -0
- package/dist/rules/md042.d.ts +22 -0
- package/dist/rules/md042.d.ts.map +1 -0
- package/dist/rules/md042.js +50 -0
- package/dist/rules/md042.js.map +1 -0
- package/dist/rules/md043.d.ts +39 -0
- package/dist/rules/md043.d.ts.map +1 -0
- package/dist/rules/md043.js +116 -0
- package/dist/rules/md043.js.map +1 -0
- package/dist/rules/md044.d.ts +40 -0
- package/dist/rules/md044.d.ts.map +1 -0
- package/dist/rules/md044.js +167 -0
- package/dist/rules/md044.js.map +1 -0
- package/dist/rules/md045.d.ts +22 -0
- package/dist/rules/md045.d.ts.map +1 -0
- package/dist/rules/md045.js +57 -0
- package/dist/rules/md045.js.map +1 -0
- package/dist/rules/md046.d.ts +23 -0
- package/dist/rules/md046.d.ts.map +1 -0
- package/dist/rules/md046.js +174 -0
- package/dist/rules/md046.js.map +1 -0
- package/dist/rules/md047.d.ts +22 -0
- package/dist/rules/md047.d.ts.map +1 -0
- package/dist/rules/md047.js +35 -0
- package/dist/rules/md047.js.map +1 -0
- package/dist/rules/md048.d.ts +22 -0
- package/dist/rules/md048.d.ts.map +1 -0
- package/dist/rules/md048.js +80 -0
- package/dist/rules/md048.js.map +1 -0
- package/dist/rules/md049.d.ts +33 -0
- package/dist/rules/md049.d.ts.map +1 -0
- package/dist/rules/md049.js +189 -0
- package/dist/rules/md049.js.map +1 -0
- package/dist/rules/md050.d.ts +22 -0
- package/dist/rules/md050.d.ts.map +1 -0
- package/dist/rules/md050.js +32 -0
- package/dist/rules/md050.js.map +1 -0
- package/dist/rules/md051.d.ts +23 -0
- package/dist/rules/md051.d.ts.map +1 -0
- package/dist/rules/md051.js +63 -0
- package/dist/rules/md051.js.map +1 -0
- package/dist/rules/md052.d.ts +21 -0
- package/dist/rules/md052.d.ts.map +1 -0
- package/dist/rules/md052.js +71 -0
- package/dist/rules/md052.js.map +1 -0
- package/dist/rules/md053.d.ts +21 -0
- package/dist/rules/md053.d.ts.map +1 -0
- package/dist/rules/md053.js +95 -0
- package/dist/rules/md053.js.map +1 -0
- package/dist/rules/md054.d.ts +21 -0
- package/dist/rules/md054.d.ts.map +1 -0
- package/dist/rules/md054.js +87 -0
- package/dist/rules/md054.js.map +1 -0
- package/dist/rules/md055.d.ts +22 -0
- package/dist/rules/md055.d.ts.map +1 -0
- package/dist/rules/md055.js +157 -0
- package/dist/rules/md055.js.map +1 -0
- package/dist/rules/md056.d.ts +21 -0
- package/dist/rules/md056.d.ts.map +1 -0
- package/dist/rules/md056.js +154 -0
- package/dist/rules/md056.js.map +1 -0
- package/dist/rules/md058.d.ts +27 -0
- package/dist/rules/md058.d.ts.map +1 -0
- package/dist/rules/md058.js +71 -0
- package/dist/rules/md058.js.map +1 -0
- package/dist/rules/md059.d.ts +22 -0
- package/dist/rules/md059.d.ts.map +1 -0
- package/dist/rules/md059.js +161 -0
- package/dist/rules/md059.js.map +1 -0
- package/dist/rules/rule-interface.d.ts +51 -0
- package/dist/rules/rule-interface.d.ts.map +1 -0
- package/dist/rules/rule-interface.js +2 -0
- package/dist/rules/rule-interface.js.map +1 -0
- package/dist/server.d.ts +59 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +419 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/file.d.ts +39 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +124 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +61 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +85 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/safe-match.d.ts +4 -0
- package/dist/utils/safe-match.d.ts.map +1 -0
- package/dist/utils/safe-match.js +51 -0
- package/dist/utils/safe-match.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { endsWithPunctuation } from '../utils/safe-match';
|
|
2
|
+
/**
|
|
3
|
+
* MD036: Emphasis used instead of a heading
|
|
4
|
+
*
|
|
5
|
+
* This rule identifies when emphasis markers like bold or italic are used to create
|
|
6
|
+
* a heading-like structure, when it would be better to use actual heading syntax.
|
|
7
|
+
*
|
|
8
|
+
* For example, the following should be converted to a proper heading:
|
|
9
|
+
* **This is a heading**
|
|
10
|
+
*
|
|
11
|
+
* It should become:
|
|
12
|
+
* ## This is a heading
|
|
13
|
+
*/
|
|
14
|
+
export const name = 'MD036';
|
|
15
|
+
export const description = 'Emphasis used instead of a heading';
|
|
16
|
+
/**
|
|
17
|
+
* Fix instances where emphasis is used instead of a heading
|
|
18
|
+
* @param lines Array of string lines to fix
|
|
19
|
+
* @param config Optional configuration object
|
|
20
|
+
* @returns Fixed lines array with proper headings
|
|
21
|
+
*/
|
|
22
|
+
export function fix(lines, config) {
|
|
23
|
+
if (lines.length === 0)
|
|
24
|
+
return lines;
|
|
25
|
+
// Default configuration
|
|
26
|
+
const punctuationConfig = config?.punctuation;
|
|
27
|
+
const result = [];
|
|
28
|
+
let inCodeBlock = false;
|
|
29
|
+
let inList = false;
|
|
30
|
+
// Regular expressions for different emphasis styles
|
|
31
|
+
const boldRegex = /^\s*(\*\*|__)(.*?)(\*\*|__)\s*$/;
|
|
32
|
+
const italicRegex = /^\s*(\*|_)(.*?)(\*|_)\s*$/;
|
|
33
|
+
// Helper to check if a line is a potential heading
|
|
34
|
+
function isEmphasisHeading(line) {
|
|
35
|
+
// Don't convert if we're in a code block or list
|
|
36
|
+
if (inCodeBlock || inList) {
|
|
37
|
+
return { isHeading: false, content: '', level: 0 };
|
|
38
|
+
}
|
|
39
|
+
// Check for bold emphasis (**text** or __text__)
|
|
40
|
+
const boldMatch = line.match(boldRegex);
|
|
41
|
+
if (boldMatch) {
|
|
42
|
+
const content = boldMatch[2].trim();
|
|
43
|
+
// Skip lines with terminal punctuation or that are too short
|
|
44
|
+
if (endsWithPunctuation(content, punctuationConfig) || content.length < 2) {
|
|
45
|
+
return { isHeading: false, content: '', level: 0 };
|
|
46
|
+
}
|
|
47
|
+
return { isHeading: true, content, level: 2 }; // Bold = h2
|
|
48
|
+
}
|
|
49
|
+
// Check for italic emphasis (*text* or _text_)
|
|
50
|
+
const italicMatch = line.match(italicRegex);
|
|
51
|
+
if (italicMatch) {
|
|
52
|
+
const content = italicMatch[2].trim();
|
|
53
|
+
// Skip lines with terminal punctuation or that are too short
|
|
54
|
+
if (endsWithPunctuation(content, punctuationConfig) || content.length < 2) {
|
|
55
|
+
return { isHeading: false, content: '', level: 0 };
|
|
56
|
+
}
|
|
57
|
+
return { isHeading: true, content, level: 3 }; // Italic = h3
|
|
58
|
+
}
|
|
59
|
+
return { isHeading: false, content: '', level: 0 };
|
|
60
|
+
}
|
|
61
|
+
// Process each line
|
|
62
|
+
for (let i = 0; i < lines.length; i++) {
|
|
63
|
+
const line = lines[i];
|
|
64
|
+
const trimmed = line.trim();
|
|
65
|
+
// Track code blocks
|
|
66
|
+
if (trimmed.startsWith('```') || trimmed.startsWith('~~~')) {
|
|
67
|
+
inCodeBlock = !inCodeBlock;
|
|
68
|
+
result.push(line);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Track lists (simple detection)
|
|
72
|
+
if (trimmed.match(/^[-+*](\s+|$)/) || trimmed.match(/^\d+\.(\s+|$)/)) {
|
|
73
|
+
inList = true;
|
|
74
|
+
result.push(line);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
else if (trimmed === '' && inList) {
|
|
78
|
+
inList = false;
|
|
79
|
+
result.push(line);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
else if (inList) {
|
|
83
|
+
result.push(line);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
// Check if this line is an emphasis heading
|
|
87
|
+
const { isHeading, content, level } = isEmphasisHeading(line);
|
|
88
|
+
if (isHeading) {
|
|
89
|
+
// Convert to a proper heading
|
|
90
|
+
const indentation = line.match(/^\s*/)?.[0] || '';
|
|
91
|
+
result.push(`${indentation}${'#'.repeat(level)} ${content}`);
|
|
92
|
+
// If the next line isn't blank, add a blank line
|
|
93
|
+
if (i < lines.length - 1 && lines[i + 1].trim() !== '') {
|
|
94
|
+
result.push('');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
result.push(line);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Rule implementation for MD036
|
|
105
|
+
*/
|
|
106
|
+
export const rule = {
|
|
107
|
+
name,
|
|
108
|
+
description,
|
|
109
|
+
fix,
|
|
110
|
+
};
|
|
111
|
+
export default rule;
|
|
112
|
+
//# sourceMappingURL=md036.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md036.js","sourceRoot":"","sources":["../../src/rules/md036.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,oCAAoC,CAAC;AAShE;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,KAAe,EAAE,MAAoB;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAErC,wBAAwB;IACxB,MAAM,iBAAiB,GAAG,MAAM,EAAE,WAA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CAAC;YAClB,SAAS;QACX,CAAC;QAED,4CAA4C;QAC5C,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE9D,IAAI,SAAS,EAAE,CAAC;YACd,8BAA8B;YAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClD,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;YAE7D,iDAAiD;YACjD,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBACvD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI;IACJ,WAAW;IACX,GAAG;CACJ,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Rule, RuleViolation } from './rule-interface';
|
|
2
|
+
/**
|
|
3
|
+
* MD037: Spaces inside emphasis markers
|
|
4
|
+
*
|
|
5
|
+
* This rule is triggered when emphasis markers (bold, italic) have spaces between
|
|
6
|
+
* the markers and the text. This is incorrect in most Markdown parsers.
|
|
7
|
+
* For example, ** bold ** should be **bold**.
|
|
8
|
+
*/
|
|
9
|
+
export declare const name = "MD037";
|
|
10
|
+
export declare const description = "Spaces inside emphasis markers";
|
|
11
|
+
/**
|
|
12
|
+
* Fix spaces inside emphasis markers by removing them
|
|
13
|
+
* @param lines Array of string lines to fix
|
|
14
|
+
* @returns Fixed lines array with proper emphasis marker spacing
|
|
15
|
+
*/
|
|
16
|
+
export declare function fix(lines: string[]): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Validate lines for spaces inside emphasis markers
|
|
19
|
+
* @param lines Array of string lines to validate
|
|
20
|
+
* @returns Array of rule violations
|
|
21
|
+
*/
|
|
22
|
+
export declare function validate(lines: string[]): RuleViolation[];
|
|
23
|
+
/**
|
|
24
|
+
* Rule implementation for MD037
|
|
25
|
+
*/
|
|
26
|
+
export declare const rule: Rule;
|
|
27
|
+
export default rule;
|
|
28
|
+
//# sourceMappingURL=md037.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md037.d.ts","sourceRoot":"","sources":["../../src/rules/md037.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,UAAU,CAAC;AAC5B,eAAO,MAAM,WAAW,mCAAmC,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA0C7C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAsEzD;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,IAKlB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MD037: Spaces inside emphasis markers
|
|
3
|
+
*
|
|
4
|
+
* This rule is triggered when emphasis markers (bold, italic) have spaces between
|
|
5
|
+
* the markers and the text. This is incorrect in most Markdown parsers.
|
|
6
|
+
* For example, ** bold ** should be **bold**.
|
|
7
|
+
*/
|
|
8
|
+
export const name = 'MD037';
|
|
9
|
+
export const description = 'Spaces inside emphasis markers';
|
|
10
|
+
/**
|
|
11
|
+
* Fix spaces inside emphasis markers by removing them
|
|
12
|
+
* @param lines Array of string lines to fix
|
|
13
|
+
* @returns Fixed lines array with proper emphasis marker spacing
|
|
14
|
+
*/
|
|
15
|
+
export function fix(lines) {
|
|
16
|
+
return lines.map(line => {
|
|
17
|
+
let fixedLine = line;
|
|
18
|
+
// Fix spaces inside bold markers (**text**)
|
|
19
|
+
fixedLine = fixedLine.replace(/\*\*(\s*)([^*]*?)(\s*)\*\*/g, (match, leadingSpaces, content, _trailingSpaces) => {
|
|
20
|
+
if (!content.trim())
|
|
21
|
+
return match; // Skip empty emphasis
|
|
22
|
+
return `**${content.trim()}**`;
|
|
23
|
+
});
|
|
24
|
+
// Fix spaces inside underscore bold markers (__text__)
|
|
25
|
+
fixedLine = fixedLine.replace(/__(\s*)([^_]*?)(\s*)__/g, (match, leadingSpaces, content, _trailingSpaces) => {
|
|
26
|
+
if (!content.trim())
|
|
27
|
+
return match; // Skip empty emphasis
|
|
28
|
+
return `__${content.trim()}__`;
|
|
29
|
+
});
|
|
30
|
+
// Fix spaces inside italic markers (*text*) - simple approach
|
|
31
|
+
fixedLine = fixedLine.replace(/(?<!\*)\*(\s*)([^*]*?)(\s*)\*(?!\*)/g, (match, leadingSpaces, content, _trailingSpaces) => {
|
|
32
|
+
if (!content.trim())
|
|
33
|
+
return match; // Skip empty emphasis
|
|
34
|
+
return `*${content.trim()}*`;
|
|
35
|
+
});
|
|
36
|
+
// Fix spaces inside underscore italic markers (_text_)
|
|
37
|
+
fixedLine = fixedLine.replace(/(?<!_)_(\s*)([^_]*?)(\s*)_(?!_)/g, (match, leadingSpaces, content, _trailingSpaces) => {
|
|
38
|
+
if (!content.trim())
|
|
39
|
+
return match; // Skip empty emphasis
|
|
40
|
+
return `_${content.trim()}_`;
|
|
41
|
+
});
|
|
42
|
+
return fixedLine;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Validate lines for spaces inside emphasis markers
|
|
47
|
+
* @param lines Array of string lines to validate
|
|
48
|
+
* @returns Array of rule violations
|
|
49
|
+
*/
|
|
50
|
+
export function validate(lines) {
|
|
51
|
+
const violations = [];
|
|
52
|
+
lines.forEach((line, index) => {
|
|
53
|
+
// Check for spaces inside bold markers (**text**)
|
|
54
|
+
const boldMatches = line.matchAll(/\*\*(\s*)([^*]*?)(\s*)\*\*/g);
|
|
55
|
+
for (const match of boldMatches) {
|
|
56
|
+
const leadingSpaces = match[1];
|
|
57
|
+
const content = match[2];
|
|
58
|
+
const trailingSpaces = match[3];
|
|
59
|
+
if (content.trim() && (leadingSpaces || trailingSpaces)) {
|
|
60
|
+
violations.push({
|
|
61
|
+
lineNumber: index + 1,
|
|
62
|
+
details: 'Spaces inside bold emphasis markers',
|
|
63
|
+
range: [match.index || 0, match[0].length],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Check for spaces inside underscore bold markers (__text__)
|
|
68
|
+
const underscoreBoldMatches = line.matchAll(/__(\s*)([^_]*?)(\s*)__/g);
|
|
69
|
+
for (const match of underscoreBoldMatches) {
|
|
70
|
+
const leadingSpaces = match[1];
|
|
71
|
+
const content = match[2];
|
|
72
|
+
const trailingSpaces = match[3];
|
|
73
|
+
if (content.trim() && (leadingSpaces || trailingSpaces)) {
|
|
74
|
+
violations.push({
|
|
75
|
+
lineNumber: index + 1,
|
|
76
|
+
details: 'Spaces inside underscore bold emphasis markers',
|
|
77
|
+
range: [match.index || 0, match[0].length],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Check for spaces inside italic markers (*text*) - simple pattern
|
|
82
|
+
const italicMatches = line.matchAll(/(?<!\*)\*(\s*)([^*]*?)(\s*)\*(?!\*)/g);
|
|
83
|
+
for (const match of italicMatches) {
|
|
84
|
+
const leadingSpaces = match[1];
|
|
85
|
+
const content = match[2];
|
|
86
|
+
const trailingSpaces = match[3];
|
|
87
|
+
if (content.trim() && (leadingSpaces || trailingSpaces)) {
|
|
88
|
+
violations.push({
|
|
89
|
+
lineNumber: index + 1,
|
|
90
|
+
details: 'Spaces inside italic emphasis markers',
|
|
91
|
+
range: [match.index || 0, match[0].length],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Check for spaces inside underscore italic markers (_text_)
|
|
96
|
+
const underscoreItalicMatches = line.matchAll(/(?<!_)_(\s*)([^_]*?)(\s*)_(?!_)/g);
|
|
97
|
+
for (const match of underscoreItalicMatches) {
|
|
98
|
+
const leadingSpaces = match[1];
|
|
99
|
+
const content = match[2];
|
|
100
|
+
const trailingSpaces = match[3];
|
|
101
|
+
if (content.trim() && (leadingSpaces || trailingSpaces)) {
|
|
102
|
+
violations.push({
|
|
103
|
+
lineNumber: index + 1,
|
|
104
|
+
details: 'Spaces inside underscore italic emphasis markers',
|
|
105
|
+
range: [match.index || 0, match[0].length],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return violations;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Rule implementation for MD037
|
|
114
|
+
*/
|
|
115
|
+
export const rule = {
|
|
116
|
+
name,
|
|
117
|
+
description,
|
|
118
|
+
validate,
|
|
119
|
+
fix,
|
|
120
|
+
};
|
|
121
|
+
export default rule;
|
|
122
|
+
//# sourceMappingURL=md037.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md037.js","sourceRoot":"","sources":["../../src/rules/md037.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,KAAe;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,SAAS,GAAG,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UAAU,EAAE,KAAK,GAAG,CAAC;oBACrB,OAAO,EAAE,kDAAkD;oBAC3D,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;iBAC3C,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI;IACJ,WAAW;IACX,QAAQ;IACR,GAAG;CACJ,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Rule, RuleViolation } from './rule-interface';
|
|
2
|
+
/**
|
|
3
|
+
* MD038: Spaces inside code span elements
|
|
4
|
+
*
|
|
5
|
+
* This rule is triggered when code span elements have spaces right after the
|
|
6
|
+
* opening backtick or right before the closing backtick. For example,
|
|
7
|
+
* ` code ` should be `code`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const name = "MD038";
|
|
10
|
+
export declare const description = "Spaces inside code span elements";
|
|
11
|
+
/**
|
|
12
|
+
* Fix spaces inside code span elements by removing them
|
|
13
|
+
* @param lines Array of string lines to fix
|
|
14
|
+
* @returns Fixed lines array with proper code span spacing
|
|
15
|
+
*/
|
|
16
|
+
export declare function fix(lines: string[]): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Validate lines for spaces inside code span elements
|
|
19
|
+
* @param lines Array of string lines to validate
|
|
20
|
+
* @returns Array of rule violations
|
|
21
|
+
*/
|
|
22
|
+
export declare function validate(lines: string[]): RuleViolation[];
|
|
23
|
+
/**
|
|
24
|
+
* Rule implementation for MD038
|
|
25
|
+
*/
|
|
26
|
+
export declare const rule: Rule;
|
|
27
|
+
export default rule;
|
|
28
|
+
//# sourceMappingURL=md038.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md038.d.ts","sourceRoot":"","sources":["../../src/rules/md038.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,UAAU,CAAC;AAC5B,eAAO,MAAM,WAAW,qCAAqC,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAgB7C;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAsBzD;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,IAKlB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MD038: Spaces inside code span elements
|
|
3
|
+
*
|
|
4
|
+
* This rule is triggered when code span elements have spaces right after the
|
|
5
|
+
* opening backtick or right before the closing backtick. For example,
|
|
6
|
+
* ` code ` should be `code`.
|
|
7
|
+
*/
|
|
8
|
+
export const name = 'MD038';
|
|
9
|
+
export const description = 'Spaces inside code span elements';
|
|
10
|
+
/**
|
|
11
|
+
* Fix spaces inside code span elements by removing them
|
|
12
|
+
* @param lines Array of string lines to fix
|
|
13
|
+
* @returns Fixed lines array with proper code span spacing
|
|
14
|
+
*/
|
|
15
|
+
export function fix(lines) {
|
|
16
|
+
return lines.map(line => {
|
|
17
|
+
// Handle spaces inside code spans with a comprehensive pattern
|
|
18
|
+
return line.replace(/`(\s*)([^`]*?)(\s*)`/g, (match, leadingSpaces, content, _trailingSpaces) => {
|
|
19
|
+
// If there's no content, return as-is (empty code span)
|
|
20
|
+
if (!content.trim()) {
|
|
21
|
+
return '``';
|
|
22
|
+
}
|
|
23
|
+
// Remove leading and trailing spaces but preserve internal content
|
|
24
|
+
return `\`${content.trim()}\``;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate lines for spaces inside code span elements
|
|
30
|
+
* @param lines Array of string lines to validate
|
|
31
|
+
* @returns Array of rule violations
|
|
32
|
+
*/
|
|
33
|
+
export function validate(lines) {
|
|
34
|
+
const violations = [];
|
|
35
|
+
lines.forEach((line, index) => {
|
|
36
|
+
// Find all code spans
|
|
37
|
+
const codeSpanMatches = line.matchAll(/`([^`]*)`/g);
|
|
38
|
+
for (const match of codeSpanMatches) {
|
|
39
|
+
const content = match[1];
|
|
40
|
+
// Check if there are leading or trailing spaces in the content
|
|
41
|
+
if (content.length > 0 && (content.startsWith(' ') || content.endsWith(' '))) {
|
|
42
|
+
violations.push({
|
|
43
|
+
lineNumber: index + 1,
|
|
44
|
+
details: 'Spaces inside code span elements',
|
|
45
|
+
range: [match.index || 0, match[0].length],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return violations;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Rule implementation for MD038
|
|
54
|
+
*/
|
|
55
|
+
export const rule = {
|
|
56
|
+
name,
|
|
57
|
+
description,
|
|
58
|
+
validate,
|
|
59
|
+
fix,
|
|
60
|
+
};
|
|
61
|
+
export default rule;
|
|
62
|
+
//# sourceMappingURL=md038.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md038.js","sourceRoot":"","sources":["../../src/rules/md038.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,kCAAkC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,KAAe;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,+DAA+D;QAC/D,OAAO,IAAI,CAAC,OAAO,CACjB,uBAAuB,EACvB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAA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
import { Rule } from './rule-interface';
|
|
2
|
+
/**
|
|
3
|
+
* MD039: Spaces inside link text
|
|
4
|
+
*
|
|
5
|
+
* This rule is triggered when there are spaces inside the square brackets
|
|
6
|
+
* of a link text or image alt text. For example, [ text ](url) should be [text](url).
|
|
7
|
+
*/
|
|
8
|
+
export declare const name = "MD039";
|
|
9
|
+
export declare const description = "Spaces inside link text";
|
|
10
|
+
/**
|
|
11
|
+
* Fix spaces inside link text by removing them
|
|
12
|
+
* @param lines Array of string lines to fix
|
|
13
|
+
* @returns Fixed lines array with proper link text formatting
|
|
14
|
+
*/
|
|
15
|
+
export declare function fix(lines: string[]): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Rule implementation for MD039
|
|
18
|
+
*/
|
|
19
|
+
export declare const rule: Rule;
|
|
20
|
+
export default rule;
|
|
21
|
+
//# sourceMappingURL=md039.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md039.d.ts","sourceRoot":"","sources":["../../src/rules/md039.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,UAAU,CAAC;AAC5B,eAAO,MAAM,WAAW,4BAA4B,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAY7C;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,IAIlB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MD039: Spaces inside link text
|
|
3
|
+
*
|
|
4
|
+
* This rule is triggered when there are spaces inside the square brackets
|
|
5
|
+
* of a link text or image alt text. For example, [ text ](url) should be [text](url).
|
|
6
|
+
*/
|
|
7
|
+
export const name = 'MD039';
|
|
8
|
+
export const description = 'Spaces inside link text';
|
|
9
|
+
/**
|
|
10
|
+
* Fix spaces inside link text by removing them
|
|
11
|
+
* @param lines Array of string lines to fix
|
|
12
|
+
* @returns Fixed lines array with proper link text formatting
|
|
13
|
+
*/
|
|
14
|
+
export function fix(lines) {
|
|
15
|
+
return lines.map(line => {
|
|
16
|
+
// Fix spaces inside link text
|
|
17
|
+
// Matches [ text ](url) and replaces with [text](url)
|
|
18
|
+
let fixedLine = line.replace(/\[\s+([^\]]+?)\s+\]\(([^)]+)\)/g, '[$1]($2)');
|
|
19
|
+
// Fix spaces inside image alt text
|
|
20
|
+
// Matches  and replaces with 
|
|
21
|
+
fixedLine = fixedLine.replace(/!\[\s+([^\]]+?)\s+\]\(([^)]+)\)/g, '');
|
|
22
|
+
return fixedLine;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Rule implementation for MD039
|
|
27
|
+
*/
|
|
28
|
+
export const rule = {
|
|
29
|
+
name,
|
|
30
|
+
description,
|
|
31
|
+
fix,
|
|
32
|
+
};
|
|
33
|
+
export default rule;
|
|
34
|
+
//# sourceMappingURL=md039.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md039.js","sourceRoot":"","sources":["../../src/rules/md039.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,KAAe;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,8BAA8B;QAC9B,sDAAsD;QACtD,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,iCAAiC,EAAE,UAAU,CAAC,CAAC;QAE5E,mCAAmC;QACnC,gEAAgE;QAChE,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,kCAAkC,EAAE,WAAW,CAAC,CAAC;QAE/E,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI;IACJ,WAAW;IACX,GAAG;CACJ,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Rule } from './rule-interface';
|
|
2
|
+
/**
|
|
3
|
+
* MD040: Fenced code blocks should have a language specified
|
|
4
|
+
*
|
|
5
|
+
* This rule is triggered when fenced code blocks do not have a language specified.
|
|
6
|
+
* Adding a language helps syntax highlighting and improves readability.
|
|
7
|
+
*/
|
|
8
|
+
export declare const name = "MD040";
|
|
9
|
+
export declare const description = "Fenced code blocks should have a language specified";
|
|
10
|
+
/**
|
|
11
|
+
* Fix code blocks by adding a default language when none is specified
|
|
12
|
+
* @param lines Array of string lines to fix
|
|
13
|
+
* @returns Fixed lines array with language added to code blocks
|
|
14
|
+
*/
|
|
15
|
+
export declare function fix(lines: string[]): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Rule implementation for MD040
|
|
18
|
+
*/
|
|
19
|
+
export declare const rule: Rule;
|
|
20
|
+
export default rule;
|
|
21
|
+
//# sourceMappingURL=md040.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md040.d.ts","sourceRoot":"","sources":["../../src/rules/md040.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,UAAU,CAAC;AAC5B,eAAO,MAAM,WAAW,wDAAwD,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAuB7C;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,IAIlB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MD040: Fenced code blocks should have a language specified
|
|
3
|
+
*
|
|
4
|
+
* This rule is triggered when fenced code blocks do not have a language specified.
|
|
5
|
+
* Adding a language helps syntax highlighting and improves readability.
|
|
6
|
+
*/
|
|
7
|
+
export const name = 'MD040';
|
|
8
|
+
export const description = 'Fenced code blocks should have a language specified';
|
|
9
|
+
/**
|
|
10
|
+
* Fix code blocks by adding a default language when none is specified
|
|
11
|
+
* @param lines Array of string lines to fix
|
|
12
|
+
* @returns Fixed lines array with language added to code blocks
|
|
13
|
+
*/
|
|
14
|
+
export function fix(lines) {
|
|
15
|
+
let fixedLines = [];
|
|
16
|
+
let inCodeBlock = false;
|
|
17
|
+
for (let i = 0; i < lines.length; i++) {
|
|
18
|
+
const line = lines[i];
|
|
19
|
+
if (!inCodeBlock && line.trim() === '```') {
|
|
20
|
+
// Add 'text' as the default language
|
|
21
|
+
fixedLines.push('```text');
|
|
22
|
+
inCodeBlock = true;
|
|
23
|
+
}
|
|
24
|
+
else if (inCodeBlock && line.trim() === '```') {
|
|
25
|
+
fixedLines.push(line);
|
|
26
|
+
inCodeBlock = false;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
fixedLines.push(line);
|
|
30
|
+
if (!inCodeBlock && line.trim().startsWith('```')) {
|
|
31
|
+
inCodeBlock = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return fixedLines;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Rule implementation for MD040
|
|
39
|
+
*/
|
|
40
|
+
export const rule = {
|
|
41
|
+
name,
|
|
42
|
+
description,
|
|
43
|
+
fix,
|
|
44
|
+
};
|
|
45
|
+
export default rule;
|
|
46
|
+
//# sourceMappingURL=md040.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md040.js","sourceRoot":"","sources":["../../src/rules/md040.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,qDAAqD,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,KAAe;IACjC,IAAI,UAAU,GAAa,EAAE,CAAC;IAC9B,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1C,qCAAqC;YACrC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3B,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;YAChD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,WAAW,GAAG,KAAK,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAClD,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI;IACJ,WAAW;IACX,GAAG;CACJ,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Rule, RuleViolation } from './rule-interface';
|
|
2
|
+
/**
|
|
3
|
+
* MD041: First line in a file should be a top-level heading
|
|
4
|
+
*
|
|
5
|
+
* This rule is triggered when the first line in a file is not a top-level heading.
|
|
6
|
+
* A top-level heading acts as the title of the document and improves document
|
|
7
|
+
* structure and accessibility. The rule can be configured to require a different
|
|
8
|
+
* heading level if needed.
|
|
9
|
+
*
|
|
10
|
+
* Note: This rule is detection-only and doesn't provide automatic fixes
|
|
11
|
+
* since adding a meaningful title requires understanding the document's content.
|
|
12
|
+
*/
|
|
13
|
+
export declare const name = "MD041";
|
|
14
|
+
export declare const description = "First line in a file should be a top-level heading";
|
|
15
|
+
/**
|
|
16
|
+
* Validate lines for first line header requirement
|
|
17
|
+
* @param lines Array of string lines to validate
|
|
18
|
+
* @returns Array of rule violations
|
|
19
|
+
*/
|
|
20
|
+
export declare function validate(lines: string[]): RuleViolation[];
|
|
21
|
+
/**
|
|
22
|
+
* Fix function for MD041
|
|
23
|
+
* Converts headers to H1, but leaves other content unchanged
|
|
24
|
+
* @param lines Array of string lines to fix
|
|
25
|
+
* @returns Fixed lines array
|
|
26
|
+
*/
|
|
27
|
+
export declare function fix(lines: string[]): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Rule implementation for MD041
|
|
30
|
+
*/
|
|
31
|
+
export declare const rule: Rule;
|
|
32
|
+
export default rule;
|
|
33
|
+
//# sourceMappingURL=md041.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md041.d.ts","sourceRoot":"","sources":["../../src/rules/md041.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,UAAU,CAAC;AAC5B,eAAO,MAAM,WAAW,uDAAuD,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAkCzD;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAgC7C;AAED;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,IAKlB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MD041: First line in a file should be a top-level heading
|
|
3
|
+
*
|
|
4
|
+
* This rule is triggered when the first line in a file is not a top-level heading.
|
|
5
|
+
* A top-level heading acts as the title of the document and improves document
|
|
6
|
+
* structure and accessibility. The rule can be configured to require a different
|
|
7
|
+
* heading level if needed.
|
|
8
|
+
*
|
|
9
|
+
* Note: This rule is detection-only and doesn't provide automatic fixes
|
|
10
|
+
* since adding a meaningful title requires understanding the document's content.
|
|
11
|
+
*/
|
|
12
|
+
export const name = 'MD041';
|
|
13
|
+
export const description = 'First line in a file should be a top-level heading';
|
|
14
|
+
/**
|
|
15
|
+
* Validate lines for first line header requirement
|
|
16
|
+
* @param lines Array of string lines to validate
|
|
17
|
+
* @returns Array of rule violations
|
|
18
|
+
*/
|
|
19
|
+
export function validate(lines) {
|
|
20
|
+
const violations = [];
|
|
21
|
+
if (lines.length === 0) {
|
|
22
|
+
return violations;
|
|
23
|
+
}
|
|
24
|
+
// Find the first non-empty, non-comment line
|
|
25
|
+
let firstLineIndex = 0;
|
|
26
|
+
while (firstLineIndex < lines.length) {
|
|
27
|
+
const line = lines[firstLineIndex].trim();
|
|
28
|
+
if (line === '' || line.startsWith('<!--')) {
|
|
29
|
+
firstLineIndex++;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
if (firstLineIndex >= lines.length) {
|
|
35
|
+
return violations; // Empty document
|
|
36
|
+
}
|
|
37
|
+
const firstLine = lines[firstLineIndex];
|
|
38
|
+
// Check if first content line is a top-level heading
|
|
39
|
+
if (!firstLine.trim().startsWith('# ')) {
|
|
40
|
+
violations.push({
|
|
41
|
+
lineNumber: firstLineIndex + 1,
|
|
42
|
+
details: 'First line in a file should be a top-level heading',
|
|
43
|
+
range: [0, firstLine.length],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return violations;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Fix function for MD041
|
|
50
|
+
* Converts headers to H1, but leaves other content unchanged
|
|
51
|
+
* @param lines Array of string lines to fix
|
|
52
|
+
* @returns Fixed lines array
|
|
53
|
+
*/
|
|
54
|
+
export function fix(lines) {
|
|
55
|
+
if (lines.length === 0) {
|
|
56
|
+
return lines;
|
|
57
|
+
}
|
|
58
|
+
// Find the first non-empty, non-comment line
|
|
59
|
+
let firstLineIndex = 0;
|
|
60
|
+
while (firstLineIndex < lines.length) {
|
|
61
|
+
const line = lines[firstLineIndex].trim();
|
|
62
|
+
if (line === '' || line.startsWith('<!--')) {
|
|
63
|
+
firstLineIndex++;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
if (firstLineIndex >= lines.length) {
|
|
69
|
+
return lines; // Empty document
|
|
70
|
+
}
|
|
71
|
+
const firstLine = lines[firstLineIndex];
|
|
72
|
+
// Only fix if it's already a header (H2-H6)
|
|
73
|
+
const headerMatch = firstLine.match(/^(#{2,6})\s+(.+)$/);
|
|
74
|
+
if (headerMatch) {
|
|
75
|
+
const newLines = [...lines];
|
|
76
|
+
newLines[firstLineIndex] = `# ${headerMatch[2]}`;
|
|
77
|
+
return newLines;
|
|
78
|
+
}
|
|
79
|
+
// Don't fix non-header content (text, lists, code, etc.)
|
|
80
|
+
return lines;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Rule implementation for MD041
|
|
84
|
+
*/
|
|
85
|
+
export const rule = {
|
|
86
|
+
name,
|
|
87
|
+
description,
|
|
88
|
+
validate,
|
|
89
|
+
fix,
|
|
90
|
+
};
|
|
91
|
+
export default rule;
|
|
92
|
+
//# sourceMappingURL=md041.js.map
|