mdbook-lint-rulesets 0.14.2

Modular rulesets for mdbook-lint - standard and mdBook-specific linting rules
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
//! Standard markdown linting rules (MD001-MD060)
//!
//! This module contains implementations of the standard markdown linting rules
//! as defined by the markdownlint specification.

// Standard markdownlint rules (MD001-MD059)
pub mod md001;
pub mod md002;
pub mod md003;
pub mod md004;
pub mod md005;
pub mod md006;
pub mod md007;
pub mod md008; // Placeholder: never implemented
pub mod md009;
pub mod md010;
pub mod md011;
pub mod md012;
pub mod md013;
pub mod md014;
pub mod md015; // Placeholder: merged into MD013
pub mod md016; // Placeholder: gap in numbering
pub mod md017; // Placeholder: covered by MD018-021
pub mod md018;
pub mod md019;
pub mod md020;
pub mod md021;
pub mod md022;
pub mod md023;
pub mod md024;
pub mod md025;
pub mod md026;
pub mod md027;
pub mod md028;
pub mod md029;
pub mod md030;
pub mod md031;
pub mod md032;
pub mod md033;
pub mod md034;
pub mod md035;
pub mod md036;
pub mod md037;
pub mod md038;
pub mod md039;
pub mod md040;
pub mod md041;
pub mod md042;
pub mod md043;
pub mod md044;
pub mod md045;
pub mod md046;
pub mod md047;
pub mod md048;
pub mod md049;
pub mod md050;
pub mod md051;
pub mod md052;
pub mod md053;
pub mod md054;
pub mod md055;
pub mod md056;
pub mod md057; // Placeholder: reserved for future use
pub mod md058;
pub mod md059;
pub mod md060;

use mdbook_lint_core::{Config, RuleProvider, RuleRegistry};

/// Provider for standard markdown rules (MD001-MD060)
pub struct StandardRuleProvider;

impl RuleProvider for StandardRuleProvider {
    fn provider_id(&self) -> &'static str {
        "standard"
    }

    fn description(&self) -> &'static str {
        "Standard markdown linting rules (MD001-MD060)"
    }

    fn version(&self) -> &'static str {
        "0.4.1"
    }

    fn register_rules(&self, registry: &mut RuleRegistry) {
        // Register all standard rules
        registry.register(Box::new(md001::MD001));
        registry.register(Box::new(md002::MD002::default()));
        registry.register(Box::new(md003::MD003::default()));
        registry.register(Box::new(md004::MD004::default()));
        registry.register(Box::new(md005::MD005));
        registry.register(Box::new(md006::MD006));
        registry.register(Box::new(md007::MD007::default()));
        // MD008 is a placeholder
        registry.register(Box::new(md009::MD009::default()));
        registry.register(Box::new(md010::MD010::default()));
        registry.register(Box::new(md011::MD011));
        registry.register(Box::new(md012::MD012::default()));
        registry.register(Box::new(md013::MD013::default()));
        registry.register(Box::new(md014::MD014));
        // MD015-017 are placeholders
        registry.register(Box::new(md018::MD018));
        registry.register(Box::new(md019::MD019));
        registry.register(Box::new(md020::MD020));
        registry.register(Box::new(md021::MD021));
        registry.register(Box::new(md022::MD022));
        registry.register(Box::new(md023::MD023));
        registry.register(Box::new(md024::MD024::default()));
        registry.register(Box::new(md025::MD025::default()));
        registry.register(Box::new(md026::MD026::default()));
        registry.register(Box::new(md027::MD027));
        registry.register(Box::new(md028::MD028));
        registry.register(Box::new(md029::MD029::default()));
        registry.register(Box::new(md030::MD030::default()));
        registry.register(Box::new(md031::MD031));
        registry.register(Box::new(md032::MD032));
        registry.register(Box::new(md033::MD033));
        registry.register(Box::new(md034::MD034));
        registry.register(Box::new(md035::MD035::default()));
        registry.register(Box::new(md036::MD036::default()));
        registry.register(Box::new(md037::MD037));
        registry.register(Box::new(md038::MD038));
        registry.register(Box::new(md039::MD039));
        registry.register(Box::new(md040::MD040));
        registry.register(Box::new(md041::MD041));
        registry.register(Box::new(md042::MD042));
        registry.register(Box::new(md043::MD043::default()));
        registry.register(Box::new(md044::MD044::default()));
        registry.register(Box::new(md045::MD045));
        registry.register(Box::new(md046::MD046::default()));
        registry.register(Box::new(md047::MD047));
        registry.register(Box::new(md048::MD048::default()));
        registry.register(Box::new(md049::MD049::default()));
        registry.register(Box::new(md050::MD050::default()));
        registry.register(Box::new(md051::MD051::default()));
        registry.register(Box::new(md052::MD052::default()));
        registry.register(Box::new(md053::MD053::default()));
        registry.register(Box::new(md054::MD054::default()));
        registry.register(Box::new(md055::MD055::default()));
        registry.register(Box::new(md056::MD056));
        // MD057 is a placeholder
        registry.register(Box::new(md058::MD058));
        registry.register(Box::new(md059::MD059::default()));
        registry.register(Box::new(md060::MD060::default()));
    }

    fn rule_ids(&self) -> Vec<&'static str> {
        vec![
            "MD001", "MD002", "MD003", "MD004", "MD005", "MD006", "MD007", "MD009", "MD010",
            "MD011", "MD012", "MD013", "MD014", "MD018", "MD019", "MD020", "MD021", "MD022",
            "MD023", "MD024", "MD025", "MD026", "MD027", "MD028", "MD029", "MD030", "MD031",
            "MD032", "MD033", "MD034", "MD035", "MD036", "MD037", "MD038", "MD039", "MD040",
            "MD041", "MD042", "MD043", "MD044", "MD045", "MD046", "MD047", "MD048", "MD049",
            "MD050", "MD051", "MD052", "MD053", "MD054", "MD055", "MD056", "MD058", "MD059",
            "MD060",
        ]
    }

    fn register_rules_with_config(&self, registry: &mut RuleRegistry, config: Option<&Config>) {
        // Register all standard rules with configuration support
        registry.register(Box::new(md001::MD001));

        // MD002 - first heading should be a top-level heading
        let md002 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD002")) {
            md002::MD002::from_config(cfg)
        } else {
            md002::MD002::default()
        };
        registry.register(Box::new(md002));

        // MD003 - heading style consistency
        let md003 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD003")) {
            md003::MD003::from_config(cfg)
        } else {
            md003::MD003::default()
        };
        registry.register(Box::new(md003));

        // MD004 - unordered list style
        let md004 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD004")) {
            md004::MD004::from_config(cfg)
        } else {
            md004::MD004::default()
        };
        registry.register(Box::new(md004));

        registry.register(Box::new(md005::MD005));
        registry.register(Box::new(md006::MD006));

        // MD007 - unordered list indentation
        let md007 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD007")) {
            md007::MD007::from_config(cfg)
        } else {
            md007::MD007::default()
        };
        registry.register(Box::new(md007));
        // MD008 is a placeholder

        // MD009 - no trailing spaces
        let md009 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD009")) {
            md009::MD009::from_config(cfg)
        } else {
            md009::MD009::default()
        };
        registry.register(Box::new(md009));

        // MD010 - hard tabs
        let md010 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD010")) {
            md010::MD010::from_config(cfg)
        } else {
            md010::MD010::default()
        };
        registry.register(Box::new(md010));

        registry.register(Box::new(md011::MD011));

        // MD012 - multiple consecutive blank lines
        let md012 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD012")) {
            md012::MD012::from_config(cfg)
        } else {
            md012::MD012::default()
        };
        registry.register(Box::new(md012));

        // MD013 - line length
        let md013 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD013")) {
            md013::MD013::from_config(cfg)
        } else {
            md013::MD013::default()
        };
        registry.register(Box::new(md013));

        registry.register(Box::new(md014::MD014));
        // MD015-017 are placeholders
        registry.register(Box::new(md018::MD018));
        registry.register(Box::new(md019::MD019));
        registry.register(Box::new(md020::MD020));
        registry.register(Box::new(md021::MD021));
        registry.register(Box::new(md022::MD022));
        registry.register(Box::new(md023::MD023));

        // MD024 - duplicate headings
        let md024 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD024")) {
            md024::MD024::from_config(cfg)
        } else {
            md024::MD024::default()
        };
        registry.register(Box::new(md024));

        // MD025 - single H1 per document
        let md025 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD025")) {
            md025::MD025::from_config(cfg)
        } else {
            md025::MD025::default()
        };
        registry.register(Box::new(md025));

        // MD026 - trailing punctuation in headings
        let md026 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD026")) {
            md026::MD026::from_config(cfg)
        } else {
            md026::MD026::default()
        };
        registry.register(Box::new(md026));

        registry.register(Box::new(md027::MD027));
        registry.register(Box::new(md028::MD028));

        // MD029 - ordered list item prefix consistency
        let md029 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD029")) {
            md029::MD029::from_config(cfg)
        } else {
            md029::MD029::default()
        };
        registry.register(Box::new(md029));

        // MD030 - spaces after list markers
        let md030 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD030")) {
            md030::MD030::from_config(cfg)
        } else {
            md030::MD030::default()
        };
        registry.register(Box::new(md030));

        registry.register(Box::new(md031::MD031));
        registry.register(Box::new(md032::MD032));
        registry.register(Box::new(md033::MD033));
        registry.register(Box::new(md034::MD034));

        // MD035 - horizontal rule style
        let md035 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD035")) {
            md035::MD035::from_config(cfg)
        } else {
            md035::MD035::default()
        };
        registry.register(Box::new(md035));

        // MD036 - emphasis used instead of a heading
        let md036 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD036")) {
            md036::MD036::from_config(cfg)
        } else {
            md036::MD036::default()
        };
        registry.register(Box::new(md036));

        registry.register(Box::new(md037::MD037));
        registry.register(Box::new(md038::MD038));
        registry.register(Box::new(md039::MD039));
        registry.register(Box::new(md040::MD040));
        registry.register(Box::new(md041::MD041));
        registry.register(Box::new(md042::MD042));

        // MD043 - required heading structure
        let md043 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD043")) {
            md043::MD043::from_config(cfg)
        } else {
            md043::MD043::default()
        };
        registry.register(Box::new(md043));

        // MD044 - proper names should have correct capitalization
        let md044 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD044")) {
            md044::MD044::from_config(cfg)
        } else {
            md044::MD044::default()
        };
        registry.register(Box::new(md044));

        registry.register(Box::new(md045::MD045));

        // MD046 - code block style consistency
        let md046 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD046")) {
            md046::MD046::from_config(cfg)
        } else {
            md046::MD046::default()
        };
        registry.register(Box::new(md046));
        registry.register(Box::new(md047::MD047));

        // MD048 - code fence style consistency
        let md048 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD048")) {
            md048::MD048::from_config(cfg)
        } else {
            md048::MD048::default()
        };
        registry.register(Box::new(md048));

        // MD049 - emphasis style consistency
        let md049 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD049")) {
            md049::MD049::from_config(cfg)
        } else {
            md049::MD049::default()
        };
        registry.register(Box::new(md049));

        // MD050 - strong style consistency
        let md050 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD050")) {
            md050::MD050::from_config(cfg)
        } else {
            md050::MD050::default()
        };
        registry.register(Box::new(md050));

        // MD051 - link fragments should be valid
        let md051 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD051")) {
            md051::MD051::from_config(cfg)
        } else {
            md051::MD051::default()
        };
        registry.register(Box::new(md051));

        // MD052 - reference links and images should use a label that is defined
        let md052 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD052")) {
            md052::MD052::from_config(cfg)
        } else {
            md052::MD052::default()
        };
        registry.register(Box::new(md052));

        // MD053 - link and image reference definitions should be needed
        let md053 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD053")) {
            md053::MD053::from_config(cfg)
        } else {
            md053::MD053::default()
        };
        registry.register(Box::new(md053));

        // MD054 - link and image style
        let md054 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD054")) {
            md054::MD054::from_config(cfg)
        } else {
            md054::MD054::default()
        };
        registry.register(Box::new(md054));

        // MD055 - table pipe style consistency
        let md055 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD055")) {
            md055::MD055::from_config(cfg)
        } else {
            md055::MD055::default()
        };
        registry.register(Box::new(md055));

        registry.register(Box::new(md056::MD056));
        // MD057 is a placeholder
        registry.register(Box::new(md058::MD058));

        // MD059 - link text should be descriptive
        let md059 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD059")) {
            md059::MD059::from_config(cfg)
        } else {
            md059::MD059::default()
        };
        registry.register(Box::new(md059));

        // MD060 - table column style consistency
        let md060 = if let Some(cfg) = config.and_then(|c| c.rule_configs.get("MD060")) {
            md060::MD060::from_config(cfg)
        } else {
            md060::MD060::default()
        };
        registry.register(Box::new(md060));
    }
}