markdownlint 0.20.0 → 0.20.4

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.
Files changed (64) hide show
  1. package/CONTRIBUTING.md +47 -47
  2. package/LICENSE +21 -21
  3. package/README.md +881 -868
  4. package/demo/markdownlint-browser.js +5438 -5306
  5. package/doc/CustomRules.md +313 -313
  6. package/doc/Rules.md +1847 -1795
  7. package/helpers/LICENSE +21 -21
  8. package/helpers/README.md +50 -50
  9. package/helpers/helpers.js +687 -627
  10. package/helpers/package.json +18 -18
  11. package/lib/cache.js +24 -24
  12. package/lib/markdownlint.d.ts +352 -352
  13. package/lib/markdownlint.js +1101 -1101
  14. package/lib/md001.js +22 -22
  15. package/lib/md002.js +22 -22
  16. package/lib/md003.js +42 -42
  17. package/lib/md004.js +43 -43
  18. package/lib/md005.js +69 -69
  19. package/lib/md006.js +34 -34
  20. package/lib/md007.js +47 -47
  21. package/lib/md009.js +77 -77
  22. package/lib/md010.js +38 -38
  23. package/lib/md011.js +38 -38
  24. package/lib/md012.js +32 -32
  25. package/lib/md013.js +99 -99
  26. package/lib/md014.js +53 -53
  27. package/lib/md018.js +34 -34
  28. package/lib/md019.js +39 -39
  29. package/lib/md020.js +62 -62
  30. package/lib/md021.js +60 -60
  31. package/lib/md022.js +56 -56
  32. package/lib/md023.js +38 -38
  33. package/lib/md024.js +38 -38
  34. package/lib/md025.js +32 -32
  35. package/lib/md026.js +40 -40
  36. package/lib/md027.js +56 -56
  37. package/lib/md028.js +38 -38
  38. package/lib/md029.js +66 -66
  39. package/lib/md030.js +50 -50
  40. package/lib/md031.js +39 -39
  41. package/lib/md032.js +50 -50
  42. package/lib/md033.js +45 -45
  43. package/lib/md034.js +61 -61
  44. package/lib/md035.js +21 -21
  45. package/lib/md036.js +56 -56
  46. package/lib/md037.js +150 -89
  47. package/lib/md038.js +68 -68
  48. package/lib/md039.js +64 -64
  49. package/lib/md040.js +18 -18
  50. package/lib/md041.js +31 -31
  51. package/lib/md042.js +41 -41
  52. package/lib/md043.js +45 -45
  53. package/lib/md044.js +77 -71
  54. package/lib/md045.js +18 -18
  55. package/lib/md046.js +32 -32
  56. package/lib/md047.js +28 -28
  57. package/lib/md048.js +29 -29
  58. package/lib/rules.js +61 -61
  59. package/package.json +73 -67
  60. package/schema/build-config-schema.js +405 -405
  61. package/schema/markdownlint-config-schema.json +1550 -1550
  62. package/style/all.json +5 -5
  63. package/style/cirosantilli.json +22 -22
  64. package/style/relaxed.json +13 -13
package/README.md CHANGED
@@ -1,868 +1,881 @@
1
- # markdownlint
2
-
3
- > A Node.js style checker and lint tool for Markdown/CommonMark files.
4
-
5
- [![npm version][npm-image]][npm-url]
6
- [![CI Status][ci-image]][ci-url]
7
- [![License][license-image]][license-url]
8
-
9
- ## Install
10
-
11
- ```shell
12
- npm install markdownlint --save-dev
13
- ```
14
-
15
- ## Overview
16
-
17
- The [Markdown](https://en.wikipedia.org/wiki/Markdown) markup language is
18
- designed to be easy to read, write, and understand. It succeeds - and its
19
- flexibility is both a benefit and a drawback. Many styles are possible, so
20
- formatting can be inconsistent. Some constructs don't work well in all
21
- parsers and should be avoided. The [CommonMark](https://commonmark.org/)
22
- specification standardizes parsers - but not authors.
23
-
24
- `markdownlint` is a
25
- [static analysis](https://en.wikipedia.org/wiki/Static_program_analysis)
26
- tool for [Node.js](https://nodejs.org/) with a library of rules
27
- to enforce standards and consistency for Markdown files. It was
28
- inspired by - and heavily influenced by - Mark Harrison's
29
- [markdownlint](https://github.com/markdownlint/markdownlint) for
30
- [Ruby](https://www.ruby-lang.org/). The initial rules, rule documentation,
31
- and test cases came directly from that project.
32
-
33
- ### Related
34
-
35
- * [markdownlint-cli command-line interface for Node.js](https://github.com/igorshubovych/markdownlint-cli)
36
- * [grunt-markdownlint for the Grunt task runner](https://github.com/sagiegurari/grunt-markdownlint)
37
- * [vscode-markdownlint extension for VS Code](https://marketplace.visualstudio.com/items/DavidAnson.vscode-markdownlint)
38
- * [Sublime Text markdownlint for Sublime Text](https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint)
39
- * [linter-node-markdownlint extension for Atom](https://atom.io/packages/linter-node-markdownlint)
40
- * [coc-markdownlint extension for Vim/Neovim](https://github.com/fannheyward/coc-markdownlint)
41
- * [markdownlint/mdl gem for Ruby](https://rubygems.org/gems/mdl)
42
- * [Cake.Markdownlint addin for Cake build automation system](https://github.com/cake-contrib/Cake.Markdownlint)
43
-
44
- ## Demonstration
45
-
46
- [`markdownlint` demo](https://dlaa.me/markdownlint/), an interactive, in-browser
47
- playground for learning and exploring.
48
-
49
- ## Rules / Aliases
50
-
51
- * **[MD001](doc/Rules.md#md001)** *heading-increment/header-increment* - Heading levels should only increment by one level at a time
52
- * ~~**[MD002](doc/Rules.md#md002)** *first-heading-h1/first-header-h1* - First heading should be a top level heading~~
53
- * **[MD003](doc/Rules.md#md003)** *heading-style/header-style* - Heading style
54
- * **[MD004](doc/Rules.md#md004)** *ul-style* - Unordered list style
55
- * **[MD005](doc/Rules.md#md005)** *list-indent* - Inconsistent indentation for list items at the same level
56
- * ~~**[MD006](doc/Rules.md#md006)** *ul-start-left* - Consider starting bulleted lists at the beginning of the line~~
57
- * **[MD007](doc/Rules.md#md007)** *ul-indent* - Unordered list indentation
58
- * **[MD009](doc/Rules.md#md009)** *no-trailing-spaces* - Trailing spaces
59
- * **[MD010](doc/Rules.md#md010)** *no-hard-tabs* - Hard tabs
60
- * **[MD011](doc/Rules.md#md011)** *no-reversed-links* - Reversed link syntax
61
- * **[MD012](doc/Rules.md#md012)** *no-multiple-blanks* - Multiple consecutive blank lines
62
- * **[MD013](doc/Rules.md#md013)** *line-length* - Line length
63
- * **[MD014](doc/Rules.md#md014)** *commands-show-output* - Dollar signs used before commands without showing output
64
- * **[MD018](doc/Rules.md#md018)** *no-missing-space-atx* - No space after hash on atx style heading
65
- * **[MD019](doc/Rules.md#md019)** *no-multiple-space-atx* - Multiple spaces after hash on atx style heading
66
- * **[MD020](doc/Rules.md#md020)** *no-missing-space-closed-atx* - No space inside hashes on closed atx style heading
67
- * **[MD021](doc/Rules.md#md021)** *no-multiple-space-closed-atx* - Multiple spaces inside hashes on closed atx style heading
68
- * **[MD022](doc/Rules.md#md022)** *blanks-around-headings/blanks-around-headers* - Headings should be surrounded by blank lines
69
- * **[MD023](doc/Rules.md#md023)** *heading-start-left/header-start-left* - Headings must start at the beginning of the line
70
- * **[MD024](doc/Rules.md#md024)** *no-duplicate-heading/no-duplicate-header* - Multiple headings with the same content
71
- * **[MD025](doc/Rules.md#md025)** *single-title/single-h1* - Multiple top level headings in the same document
72
- * **[MD026](doc/Rules.md#md026)** *no-trailing-punctuation* - Trailing punctuation in heading
73
- * **[MD027](doc/Rules.md#md027)** *no-multiple-space-blockquote* - Multiple spaces after blockquote symbol
74
- * **[MD028](doc/Rules.md#md028)** *no-blanks-blockquote* - Blank line inside blockquote
75
- * **[MD029](doc/Rules.md#md029)** *ol-prefix* - Ordered list item prefix
76
- * **[MD030](doc/Rules.md#md030)** *list-marker-space* - Spaces after list markers
77
- * **[MD031](doc/Rules.md#md031)** *blanks-around-fences* - Fenced code blocks should be surrounded by blank lines
78
- * **[MD032](doc/Rules.md#md032)** *blanks-around-lists* - Lists should be surrounded by blank lines
79
- * **[MD033](doc/Rules.md#md033)** *no-inline-html* - Inline HTML
80
- * **[MD034](doc/Rules.md#md034)** *no-bare-urls* - Bare URL used
81
- * **[MD035](doc/Rules.md#md035)** *hr-style* - Horizontal rule style
82
- * **[MD036](doc/Rules.md#md036)** *no-emphasis-as-heading/no-emphasis-as-header* - Emphasis used instead of a heading
83
- * **[MD037](doc/Rules.md#md037)** *no-space-in-emphasis* - Spaces inside emphasis markers
84
- * **[MD038](doc/Rules.md#md038)** *no-space-in-code* - Spaces inside code span elements
85
- * **[MD039](doc/Rules.md#md039)** *no-space-in-links* - Spaces inside link text
86
- * **[MD040](doc/Rules.md#md040)** *fenced-code-language* - Fenced code blocks should have a language specified
87
- * **[MD041](doc/Rules.md#md041)** *first-line-heading/first-line-h1* - First line in file should be a top level heading
88
- * **[MD042](doc/Rules.md#md042)** *no-empty-links* - No empty links
89
- * **[MD043](doc/Rules.md#md043)** *required-headings/required-headers* - Required heading structure
90
- * **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
91
- * **[MD045](doc/Rules.md#md045)** *no-alt-text* - Images should have alternate text (alt text)
92
- * **[MD046](doc/Rules.md#md046)** *code-block-style* - Code block style
93
- * **[MD047](doc/Rules.md#md047)** *single-trailing-newline* - Files should end with a single newline character
94
- * **[MD048](doc/Rules.md#md048)** *code-fence-style* - Code fence style
95
-
96
- See [Rules.md](doc/Rules.md) for more details.
97
-
98
- ~~Struck through~~ rules are deprecated, and provided for backward-compatibility.
99
-
100
- > All rules with `heading` as part of their name are also available as `header`
101
- > aliases (e.g. `heading-increment` is also available as `header-increment`).
102
- > The use of `header` is deprecated and provided for backward-compatibility.
103
-
104
- ## Tags
105
-
106
- Tags group related rules and can be used to enable/disable multiple rules at once.
107
-
108
- * **accessibility** - MD045
109
- * **atx** - MD018, MD019
110
- * **atx_closed** - MD020, MD021
111
- * **blank_lines** - MD012, MD022, MD031, MD032, MD047
112
- * **blockquote** - MD027, MD028
113
- * **bullet** - MD004, MD005, MD006, MD007, MD032
114
- * **code** - MD014, MD031, MD038, MD040, MD046, MD048
115
- * **emphasis** - MD036, MD037
116
- * **hard_tab** - MD010
117
- * **headers** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023,
118
- MD024, MD025, MD026, MD036, MD041, MD043
119
- * **headings** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023,
120
- MD024, MD025, MD026, MD036, MD041, MD043
121
- * **hr** - MD035
122
- * **html** - MD033
123
- * **images** - MD045
124
- * **indentation** - MD005, MD006, MD007, MD027
125
- * **language** - MD040
126
- * **line_length** - MD013
127
- * **links** - MD011, MD034, MD039, MD042
128
- * **ol** - MD029, MD030, MD032
129
- * **spaces** - MD018, MD019, MD020, MD021, MD023
130
- * **spelling** - MD044
131
- * **ul** - MD004, MD005, MD006, MD007, MD030, MD032
132
- * **url** - MD034
133
- * **whitespace** - MD009, MD010, MD012, MD027, MD028, MD030, MD037, MD038, MD039
134
-
135
- ## Configuration
136
-
137
- Text passed to `markdownlint` is parsed as Markdown, analyzed, and any issues reported.
138
- Two kinds of text are ignored:
139
-
140
- * [HTML comments](https://www.w3.org/TR/html5/syntax.html#comments)
141
- * [Front matter](https://jekyllrb.com/docs/frontmatter/) (see `options.frontMatter` below)
142
-
143
- Rules can be enabled, disabled, and configured via `options.config` (described
144
- below) to define the expected behavior for a set of inputs. To enable or disable
145
- rules at a particular location within a file, add one of these markers to the
146
- appropriate place (HTML comments don't appear in the final markup):
147
-
148
- * Disable all rules: `<!-- markdownlint-disable -->`
149
- * Enable all rules: `<!-- markdownlint-enable -->`
150
- * Disable one or more rules by name: `<!-- markdownlint-disable MD001 MD005 -->`
151
- * Enable one or more rules by name: `<!-- markdownlint-enable MD001 MD005 -->`
152
- * Capture the current rule configuration: `<!-- markdownlint-capture -->`
153
- * Restore the captured rule configuration: `<!-- markdownlint-restore -->`
154
-
155
- For example:
156
-
157
- ```markdown
158
- <!-- markdownlint-disable no-space-in-emphasis -->
159
- deliberate space * in * emphasis
160
- <!-- markdownlint-enable no-space-in-emphasis -->
161
- ```
162
-
163
- To temporarily disable rule(s), then restore the former configuration:
164
-
165
- ```markdown
166
- <!-- markdownlint-capture -->
167
- <!-- markdownlint-disable -->
168
- any violations you want
169
- <!-- markdownlint-restore -->
170
- ```
171
-
172
- The initial configuration is captured by default (as if every document began
173
- with `<!-- markdownlint-capture -->`), so the pattern above can be expressed
174
- more simply:
175
-
176
- ```markdown
177
- <!-- markdownlint-disable -->
178
- any violations you want
179
- <!-- markdownlint-restore -->
180
- ```
181
-
182
- Changes take effect starting with the line a comment is on, so the following
183
- has no effect:
184
-
185
- ```markdown
186
- space * in * emphasis <!-- markdownlint-disable --> <!-- markdownlint-enable -->
187
- ```
188
-
189
- To apply changes to an entire file regardless of where the comment is located,
190
- the following syntax is supported:
191
-
192
- * Disable all rules: `<!-- markdownlint-disable-file -->`
193
- * Enable all rules: `<!-- markdownlint-enable-file -->`
194
- * Disable one or more rules by name: `<!-- markdownlint-disable-file MD001 -->`
195
- * Enable one or more rules by name: `<!-- markdownlint-enable-file MD001 -->`
196
-
197
- This can be used to "hide" `markdownlint` comments at the bottom of a file.
198
-
199
- In cases where it is desirable to change the configuration of one or more rules
200
- for a file, the following more advanced syntax is supported:
201
-
202
- * Confiure: `<!-- markdownlint-configure-file { options.config JSON } -->`
203
-
204
- For example:
205
-
206
- ```markdown
207
- <!-- markdownlint-configure-file { "MD013": { "line_length": 70 } } -->
208
- ```
209
-
210
- or
211
-
212
- ```markdown
213
- <!-- markdownlint-configure-file
214
- {
215
- "hr-style": {
216
- "style": "---"
217
- },
218
- "no-trailing-spaces": false
219
- }
220
- -->
221
- ```
222
-
223
- These changes apply to the entire file regardless of where the comment is
224
- located. Multiple such comments (if present) are applied top-to-bottom.
225
-
226
- ## API
227
-
228
- ### Linting
229
-
230
- Standard asynchronous interface:
231
-
232
- ```js
233
- /**
234
- * Lint specified Markdown files.
235
- *
236
- * @param {Object} options Configuration options.
237
- * @param {Function} callback Callback (err, result) function.
238
- * @returns {void}
239
- */
240
- function markdownlint(options, callback) { ... }
241
- ```
242
-
243
- Synchronous interface (for build scripts, etc.):
244
-
245
- ```js
246
- /**
247
- * Lint specified Markdown files synchronously.
248
- *
249
- * @param {Object} options Configuration options.
250
- * @returns {Object} Result object.
251
- */
252
- function markdownlint.sync(options) { ... }
253
- ```
254
-
255
- #### options
256
-
257
- Type: `Object`
258
-
259
- Configures the function.
260
-
261
- ##### options.customRules
262
-
263
- Type: `Array` of `Object`
264
-
265
- List of custom rules to include with the default rule set for linting.
266
-
267
- Each array element should define a rule. Rules are typically exported by another
268
- package, but can be defined inline.
269
-
270
- Example:
271
-
272
- ```js
273
- const extraRules = require("extraRules");
274
- const options = {
275
- "customRules": [ extraRules.one, extraRules.two ]
276
- };
277
- ```
278
-
279
- See [CustomRules.md](doc/CustomRules.md) for details about authoring custom rules.
280
-
281
- ##### options.files
282
-
283
- Type: `Array` of `String`
284
-
285
- List of files to lint.
286
-
287
- Each array element should be a single file (via relative or absolute path);
288
- [globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the caller's
289
- responsibility.
290
-
291
- Example: `[ "one.md", "dir/two.md" ]`
292
-
293
- ##### options.strings
294
-
295
- Type: `Object` mapping `String` to `String`
296
-
297
- Map of identifiers to strings for linting.
298
-
299
- When Markdown content is not available as files, it can be passed as strings.
300
- The keys of the `strings` object are used to identify each input value in the
301
- `result` summary.
302
-
303
- Example:
304
-
305
- ```json
306
- {
307
- "readme": "# README\n...",
308
- "changelog": "# CHANGELOG\n..."
309
- }
310
- ```
311
-
312
- ##### options.config
313
-
314
- Type: `Object` mapping `String` to `Boolean | Object`
315
-
316
- Configures the rules to use.
317
-
318
- Object keys are rule names or aliases and values are the rule's configuration.
319
- The value `false` disables a rule, `true` enables its default configuration,
320
- and passing an object customizes its settings. Setting the special `default`
321
- rule to `true` or `false` includes/excludes all rules by default. Enabling or
322
- disabling a tag name (ex: `whitespace`) affects all rules having that tag.
323
-
324
- The `default` rule is applied first, then keys are processed in order from top
325
- to bottom with later values overriding earlier ones. Keys (including rule names,
326
- aliases, tags, and `default`) are not case-sensitive.
327
-
328
- Example:
329
-
330
- ```json
331
- {
332
- "default": true,
333
- "MD003": { "style": "atx_closed" },
334
- "MD007": { "indent": 4 },
335
- "no-hard-tabs": false,
336
- "whitespace": false
337
- }
338
- ```
339
-
340
- Sets of rules (known as a "style") can be stored separately and loaded as
341
- [JSON](https://en.wikipedia.org/wiki/JSON).
342
-
343
- Example:
344
-
345
- ```js
346
- const options = {
347
- "files": [ "..." ],
348
- "config": require("style/relaxed.json")
349
- };
350
- ```
351
-
352
- See the [style](style) directory for more samples.
353
-
354
- See [markdownlint-config-schema.json](schema/markdownlint-config-schema.json)
355
- for the [JSON Schema](https://json-schema.org/) of the `options.config` object.
356
-
357
- For more advanced scenarios, styles can reference and extend other styles. The
358
- `readConfig` and `readConfigSync` functions can be used to read such styles.
359
-
360
- For example, assuming a `base.json` configuration file:
361
-
362
- ```json
363
- {
364
- "default": true
365
- }
366
- ```
367
-
368
- And a `custom.json` configuration file:
369
-
370
- ```json
371
- {
372
- "extends": "base.json",
373
- "line-length": false
374
- }
375
- ```
376
-
377
- Then code like the following:
378
-
379
- ```js
380
- const options = {
381
- "config": markdownlint.readConfigSync("./custom.json")
382
- };
383
- ```
384
-
385
- Merges `custom.json` and `base.json` and is equivalent to:
386
-
387
- ```js
388
- const options = {
389
- "config": {
390
- "default": true,
391
- "line-length": false
392
- }
393
- };
394
- ```
395
-
396
- ##### options.frontMatter
397
-
398
- Type: `RegExp`
399
-
400
- Matches any [front matter](https://jekyllrb.com/docs/frontmatter/) found at the
401
- beginning of a file.
402
-
403
- Some Markdown content begins with metadata; the default `RegExp` for this option
404
- ignores common forms of "front matter". To match differently, specify a custom
405
- `RegExp` or use the value `null` to disable the feature.
406
-
407
- The default value:
408
-
409
- ```js
410
- /((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m
411
- ```
412
-
413
- Ignores [YAML](https://en.wikipedia.org/wiki/YAML) and
414
- [TOML](https://en.wikipedia.org/wiki/TOML) such as:
415
-
416
- ```text
417
- ---
418
- layout: post
419
- title: Title
420
- ---
421
- ```
422
-
423
- Note: Matches must occur at the start of the file.
424
-
425
- ##### options.handleRuleFailures
426
-
427
- Type: `Boolean`
428
-
429
- Catches exceptions thrown during rule processing and reports the problem as a
430
- rule violation.
431
-
432
- By default, exceptions thrown by rules (or the library itself) are unhandled
433
- and bubble up the stack to the caller in the conventional manner. By setting
434
- `handleRuleFailures` to `true`, exceptions thrown by failing rules will be
435
- handled by the library and the exception message logged as a rule violation.
436
- This setting can be useful in the presence of (custom) rules that encounter
437
- unexpected syntax and fail. By enabling this option, the linting process is
438
- allowed to continue and report any violations that were found.
439
-
440
- ##### options.noInlineConfig
441
-
442
- Type: `Boolean`
443
-
444
- Disables the use of HTML comments like `<!-- markdownlint-disable -->` to toggle
445
- rules within the body of Markdown content.
446
-
447
- By default, properly-formatted inline comments can be used to create exceptions
448
- for parts of a document. Setting `noInlineConfig` to `true` ignores all such
449
- comments.
450
-
451
- ##### options.resultVersion
452
-
453
- Type: `Number`
454
-
455
- Specifies which version of the `result` object to return (see the "Usage" section
456
- below for examples).
457
-
458
- Passing a `resultVersion` of `0` corresponds to the original, simple format where
459
- each error is identified by rule name and line number. *This is deprecated.*
460
-
461
- Passing a `resultVersion` of `1` corresponds to a detailed format where each error
462
- includes information about the line number, rule name, alias, description, as well
463
- as any additional detail or context that is available. *This is deprecated.*
464
-
465
- Passing a `resultVersion` of `2` corresponds to a detailed format where each error
466
- includes information about the line number, rule names, description, as well as any
467
- additional detail or context that is available. *This is the default.*
468
-
469
- Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
470
- with additional information about how to fix automatically-fixable errors. In this
471
- mode, all errors that occur on each line are reported (other versions report only
472
- the first error for each rule).
473
-
474
- ##### options.markdownItPlugins
475
-
476
- Type: `Array` of `Array` of `Function` and plugin parameters
477
-
478
- Specifies additional [markdown-it plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin)
479
- to use when parsing input. Plugins can be used to support additional syntax and
480
- features for advanced scenarios.
481
-
482
- Each item in the top-level `Array` should be of the form:
483
-
484
- ```js
485
- [ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
486
- ```
487
-
488
- #### callback
489
-
490
- Type: `Function` taking (`Error`, `Object`)
491
-
492
- Standard completion callback.
493
-
494
- #### result
495
-
496
- Type: `Object`
497
-
498
- Call `result.toString()` for convenience or see below for an example of the
499
- structure of the `result` object. Passing the value `true` to `toString()`
500
- uses rule aliases (ex: `no-hard-tabs`) instead of names (ex: `MD010`).
501
-
502
- ### Config
503
-
504
- The `options.config` configuration object is simple and can be stored in a file
505
- for readability and easy reuse. The `readConfig` and `readConfigSync` functions
506
- load configuration settings and support the `extends` keyword for referencing
507
- other files (see above).
508
-
509
- By default, configuration files are parsed as JSON (and named `.markdownlint.json`).
510
- Custom parsers can be provided to handle other formats like JSONC, YAML, and TOML.
511
-
512
- Asynchronous interface:
513
-
514
- ```js
515
- /**
516
- * Read specified configuration file.
517
- *
518
- * @param {String} file Configuration file name/path.
519
- * @param {Array} [parsers] Optional parsing function(s).
520
- * @param {Function} callback Callback (err, result) function.
521
- * @returns {void}
522
- */
523
- function readConfig(file, parsers, callback) { ... }
524
- ```
525
-
526
- Synchronous interface:
527
-
528
- ```js
529
- /**
530
- * Read specified configuration file synchronously.
531
- *
532
- * @param {String} file Configuration file name/path.
533
- * @param {Array} [parsers] Optional parsing function(s).
534
- * @returns {Object} Configuration object.
535
- */
536
- function readConfigSync(file, parsers) { ... }
537
- ```
538
-
539
- #### file
540
-
541
- Type: `String`
542
-
543
- Location of configuration file to read.
544
-
545
- The `file` is resolved relative to the current working directory. If an `extends`
546
- key is present once read, its value will be resolved as a path relative to `file`
547
- and loaded recursively. Settings from a file referenced by `extends` are applied
548
- first, then those of `file` are applied on top (overriding any of the same keys
549
- appearing in the referenced file).
550
-
551
- #### parsers
552
-
553
- Type: *Optional* `Array` of `Function` taking (`String`) and returning `Object`
554
-
555
- Array of functions to parse configuration files.
556
-
557
- The contents of a configuration file are passed to each parser function until one
558
- of them returns a value (vs. throwing an exception). Consequently, strict parsers
559
- should come before flexible parsers.
560
-
561
- For example:
562
-
563
- ```js
564
- [ JSON.parse, require("toml").parse, require("js-yaml").safeLoad ]
565
- ```
566
-
567
- #### callback
568
-
569
- Type: `Function` taking (`Error`, `Object`)
570
-
571
- Standard completion callback.
572
-
573
- #### result
574
-
575
- Type: `Object`
576
-
577
- Configuration object.
578
-
579
- ## Usage
580
-
581
- Invoke `markdownlint` and use the `result` object's `toString` method:
582
-
583
- ```js
584
- const markdownlint = require("markdownlint");
585
-
586
- const options = {
587
- "files": [ "good.md", "bad.md" ],
588
- "strings": {
589
- "good.string": "# good.string\n\nThis string passes all rules.",
590
- "bad.string": "#bad.string\n\n#This string fails\tsome rules."
591
- }
592
- };
593
-
594
- markdownlint(options, function callback(err, result) {
595
- if (!err) {
596
- console.log(result.toString());
597
- }
598
- });
599
- ```
600
-
601
- Output:
602
-
603
- ```text
604
- bad.string: 3: MD010/no-hard-tabs Hard tabs [Column: 19]
605
- bad.string: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.string"]
606
- bad.string: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This string fails some rules."]
607
- bad.string: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.string"]
608
- bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
609
- bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
610
- bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
611
- bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
612
- ```
613
-
614
- Or invoke `markdownlint.sync` for a synchronous call:
615
-
616
- ```js
617
- const result = markdownlint.sync(options);
618
- console.log(result.toString());
619
- ```
620
-
621
- To examine the `result` object directly:
622
-
623
- ```js
624
- markdownlint(options, function callback(err, result) {
625
- if (!err) {
626
- console.dir(result, { "colors": true, "depth": null });
627
- }
628
- });
629
- ```
630
-
631
- Output:
632
-
633
- ```json
634
- {
635
- "good.md": [],
636
- "bad.md": [
637
- { "lineNumber": 3,
638
- "ruleNames": [ "MD010", "no-hard-tabs" ],
639
- "ruleDescription": "Hard tabs",
640
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
641
- "errorDetail": "Column: 17",
642
- "errorContext": null,
643
- "errorRange": [ 17, 1 ] },
644
- { "lineNumber": 1,
645
- "ruleNames": [ "MD018", "no-missing-space-atx" ],
646
- "ruleDescription": "No space after hash on atx style heading",
647
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
648
- "errorDetail": null,
649
- "errorContext": "#bad.md",
650
- "errorRange": [ 1, 2 ] },
651
- { "lineNumber": 3,
652
- "ruleNames": [ "MD018", "no-missing-space-atx" ],
653
- "ruleDescription": "No space after hash on atx style heading",
654
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
655
- "errorDetail": null,
656
- "errorContext": "#This file fails\tsome rules.",
657
- "errorRange": [ 1, 2 ] },
658
- { "lineNumber": 1,
659
- "ruleNames": [ "MD041", "first-line-heading", "first-line-h1" ],
660
- "ruleDescription": "First line in file should be a top level heading",
661
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md041",
662
- "errorDetail": null,
663
- "errorContext": "#bad.md",
664
- "errorRange": null }
665
- ]
666
- }
667
- ```
668
-
669
- Integration with the [gulp](https://gulpjs.com/) build system is straightforward:
670
-
671
- ```js
672
- const gulp = require("gulp");
673
- const through2 = require("through2");
674
- const markdownlint = require("markdownlint");
675
-
676
- gulp.task("markdownlint", function task() {
677
- return gulp.src("*.md", { "read": false })
678
- .pipe(through2.obj(function obj(file, enc, next) {
679
- markdownlint(
680
- { "files": [ file.relative ] },
681
- function callback(err, result) {
682
- const resultString = (result || "").toString();
683
- if (resultString) {
684
- console.log(resultString);
685
- }
686
- next(err, file);
687
- });
688
- }));
689
- });
690
- ```
691
-
692
- Output:
693
-
694
- ```text
695
- [00:00:00] Starting 'markdownlint'...
696
- bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
697
- bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
698
- bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
699
- bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
700
- [00:00:00] Finished 'markdownlint' after 10 ms
701
- ```
702
-
703
- Integration with the [Grunt](https://gruntjs.com/) build system is similar:
704
-
705
- ```js
706
- const markdownlint = require("markdownlint");
707
-
708
- module.exports = function wrapper(grunt) {
709
- grunt.initConfig({
710
- "markdownlint": {
711
- "example": {
712
- "src": [ "*.md" ]
713
- }
714
- }
715
- });
716
-
717
- grunt.registerMultiTask("markdownlint", function task() {
718
- const done = this.async();
719
- markdownlint(
720
- { "files": this.filesSrc },
721
- function callback(err, result) {
722
- const resultString = err || ((result || "").toString());
723
- if (resultString) {
724
- grunt.fail.warn("\n" + resultString + "\n");
725
- }
726
- done(!err || !resultString);
727
- });
728
- });
729
- };
730
- ```
731
-
732
- Output:
733
-
734
- ```text
735
- Running "markdownlint:example" (markdownlint) task
736
- Warning:
737
- bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
738
- bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
739
- bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
740
- bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
741
- Use --force to continue.
742
- ```
743
-
744
- ## Browser
745
-
746
- `markdownlint` also works in the browser.
747
-
748
- Generate normal and minified scripts with:
749
-
750
- ```shell
751
- npm run build-demo
752
- ```
753
-
754
- Then reference `markdown-it` and `markdownlint`:
755
-
756
- ```html
757
- <script src="demo/markdown-it.min.js"></script>
758
- <script src="demo/markdownlint-browser.min.js"></script>
759
- ```
760
-
761
- And call it like so:
762
-
763
- ```js
764
- const options = {
765
- "strings": {
766
- "content": "Some Markdown to lint."
767
- }
768
- };
769
- const results = window.markdownlint.sync(options).toString();
770
- ```
771
-
772
- ## Examples
773
-
774
- For ideas how to integrate `markdownlint` into your workflow, refer to the following projects:
775
-
776
- * [.NET Documentation](https://docs.microsoft.com/en-us/dotnet/) ([Search repository](https://github.com/dotnet/docs/search?q=markdownlint))
777
- * [ally.js](https://allyjs.io/) ([Search repository](https://github.com/medialize/ally.js/search?q=markdownlint))
778
- * [Boostnote](https://boostnote.io/) ([Search repository](https://github.com/BoostIO/Boostnote/search?q=markdownlint))
779
- * [CodiMD](https://github.com/hackmdio/codimd) ([Search repository](https://github.com/hackmdio/codimd/search?q=markdownlint))
780
- * [ESLint](https://eslint.org/) ([Search repository](https://github.com/eslint/eslint/search?q=markdownlint))
781
- * [Garden React Components](https://garden.zendesk.com/react-components/) ([Search repository](https://github.com/zendeskgarden/react-components/search?q=markdownlint))
782
- * [Mocha](https://mochajs.org/) ([Search repository](https://github.com/mochajs/mocha/search?q=markdownlint))
783
- * [Reactable](https://glittershark.github.io/reactable/) ([Search repository](https://github.com/glittershark/reactable/search?q=markdownlint))
784
- * [Sinon.JS](https://sinonjs.org/) ([Search repository](https://github.com/sinonjs/sinon/search?q=markdownlint))
785
- * [TestCafe](https://devexpress.github.io/testcafe/) ([Search repository](https://github.com/DevExpress/testcafe/search?q=markdownlint))
786
- * [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html) ([Search repository](https://github.com/Microsoft/TypeScript-Handbook/search?q=markdownlint))
787
- * [V8](https://v8.dev/) ([Search repository](https://github.com/v8/v8.dev/search?q=markdownlint))
788
- * [webhint](https://webhint.io/) ([Search repository](https://github.com/webhintio/hint/search?q=markdownlint))
789
- * [webpack](https://webpack.js.org/) ([Search repository](https://github.com/webpack/webpack.js.org/search?q=markdownlint))
790
-
791
- ## Contributing
792
-
793
- See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
794
-
795
- ## History
796
-
797
- * 0.0.1 - Initial release, includes tests MD001-MD032.
798
- * 0.0.2 - Improve documentation, tests, and code.
799
- * 0.0.3 - Add synchronous API, improve documentation and code.
800
- * 0.0.4 - Add tests MD033-MD040, update dependencies.
801
- * 0.0.5 - Add `strings` option to enable file-less scenarios, add in-browser demo.
802
- * 0.0.6 - Improve performance, simplify in-browser, update dependencies.
803
- * 0.0.7 - Add MD041, improve MD003, ignore front matter, update dependencies.
804
- * 0.0.8 - Support disabling/enabling rules inline, improve code fence, dependencies.
805
- * 0.1.0 - Add aliases, exceptions for MD033, exclusions for MD013, dependencies.
806
- * 0.1.1 - Fix bug handling HTML in tables, reference markdownlint-cli.
807
- * 0.2.0 - Add MD042/MD043, enhance MD002/MD003/MD004/MD007/MD011/MD025/MD041, dependencies.
808
- * 0.3.0 - More detailed error reporting with `resultVersion`, enhance MD010/MD012/MD036,
809
- fixes for MD027/MD029/MD030, include JSON schema, dependencies.
810
- * 0.3.1 - Fix regressions in MD032/MD038, update dependencies.
811
- * 0.4.0 - Add MD044, enhance MD013/MD032/MD041/MD042/MD043, fix for MD038, dependencies.
812
- * 0.4.1 - Fixes for MD038/front matter, improvements to MD044, update dependencies.
813
- * 0.5.0 - Add shareable configuration, `noInlineConfig` option, README links, fix MD030,
814
- improve MD009/MD041, update dependencies.
815
- * 0.6.0 - `resultVersion` defaults to 1 (breaking change), ignore HTML comments, TOML
816
- front matter, fixes for MD044, update dependencies.
817
- * 0.6.1 - Update `markdown-it` versioning, exclude demo/test from publishing.
818
- * 0.6.2 - Improve MD013/MD027/MD034/MD037/MD038/MD041/MD044, update dependencies.
819
- * 0.6.3 - Improve highlighting for MD020.
820
- * 0.6.4 - Improve MD029/MD042, update dependencies.
821
- * 0.7.0 - `resultVersion` defaults to 2 (breaking change), add MD045, improve MD029,
822
- remove trimLeft/trimRight, split rules, refactor, update dependencies.
823
- * 0.8.0 - Add support for using and authoring custom rules, improve MD004/MD007/MD013,
824
- add `engines` to `package.json`, refactor, update dependencies.
825
- * 0.8.1 - Update item loop to be iterative, improve MD014, update dependencies.
826
- * 0.9.0 - Remove support for end-of-life Node versions 0.10/0.12/4, change "header" to
827
- "heading" per spec (non-breaking), improve MD003/MD009/MD041, handle uncommon
828
- line-break characters, refactor for ES6, update dependencies.
829
- * 0.10.0 - Add support for non-JSON configuration files, pass file/string name to custom
830
- rules, update dependencies.
831
- * 0.11.0 - Improve MD005/MD024/MD029/MD038, improve custom rule example, add CONTRIBUTING.md,
832
- update dependencies.
833
- * 0.12.0 - Add `information` link for custom rules, `markdownItPlugins` for extensibility,
834
- improve MD023/MD032/MD038, update dependencies.
835
- * 0.13.0 - Improve MD013/MD022/MD025/MD029/MD031/MD032/MD037/MD041/, deprecate MD002,
836
- improve pandoc YAML support, update dependencies.
837
- * 0.14.0 - Remove support for end-of-life Node version 6, introduce `markdownlint-rule-helpers`,
838
- add MD046/MD047, improve MD033/MD034/MD039, improve custom rule validation and
839
- in-browser demo, update dependencies.
840
- * 0.14.1 - Improve MD033.
841
- * 0.14.2 - Improve MD047, add `handleRuleFailures` option.
842
- * 0.15.0 - Add `markdownlint-capture`/`markdownlint-restore` inline comments, improve
843
- MD009/MD013/MD026/MD033/MD036, update dependencies.
844
- * 0.16.0 - Add custom rule sample for linting code, improve MD026/MD031/MD033/MD038,
845
- update dependencies.
846
- * 0.17.0 - Add `resultVersion` 3 to support fix information for default and custom rules,
847
- add fix information for 24 rules, update newline handling to match latest
848
- CommonMark specification, improve MD014/MD037/MD039, update dependencies.
849
- * 0.17.1 - Fix handling of front matter by fix information.
850
- * 0.17.2 - Improve MD020/MD033/MD044.
851
- * 0.18.0 - Add MD048/code-fence-style, add fix information for MD007/ul-indent, add
852
- `markdownlint-disable-file`/`markdownlint-enable-file` inline comments, add
853
- type declaration file (.d.ts) for TypeScript dependents, update schema, improve
854
- MD006/MD007/MD009/MD013/MD030, update dependencies.
855
- * 0.19.0 - Remove support for end-of-life Node version 8, add fix information for
856
- MD005/list-indent, improve MD007/MD013/MD014, deprecate MD006/ul-start-left, add
857
- rationale for every rule, update test runner and code coverage, add more JSDoc
858
- comments, update dependencies.
859
- * 0.20.0 - Add `markdownlint-configure-file` inline comment,
860
- improve MD005/MD007/MD013/MD018/MD029/MD031/MD034/MD037/MD038/MD039, improve HTML
861
- comment handling, update dependencies.
862
-
863
- [npm-image]: https://img.shields.io/npm/v/markdownlint.svg
864
- [npm-url]: https://www.npmjs.com/package/markdownlint
865
- [ci-image]: https://github.com/DavidAnson/markdownlint/workflows/CI/badge.svg?branch=master
866
- [ci-url]: https://github.com/DavidAnson/markdownlint/actions?query=branch%3Amaster
867
- [license-image]: https://img.shields.io/npm/l/markdownlint.svg
868
- [license-url]: https://opensource.org/licenses/MIT
1
+ # markdownlint
2
+
3
+ > A Node.js style checker and lint tool for Markdown/CommonMark files.
4
+
5
+ [![npm version][npm-image]][npm-url]
6
+ [![CI Status][ci-image]][ci-url]
7
+ [![License][license-image]][license-url]
8
+
9
+ ## Install
10
+
11
+ ```shell
12
+ npm install markdownlint --save-dev
13
+ ```
14
+
15
+ ## Overview
16
+
17
+ The [Markdown](https://en.wikipedia.org/wiki/Markdown) markup language is
18
+ designed to be easy to read, write, and understand. It succeeds - and its
19
+ flexibility is both a benefit and a drawback. Many styles are possible, so
20
+ formatting can be inconsistent. Some constructs don't work well in all
21
+ parsers and should be avoided. The [CommonMark](https://commonmark.org/)
22
+ specification standardizes parsers - but not authors.
23
+
24
+ `markdownlint` is a
25
+ [static analysis](https://en.wikipedia.org/wiki/Static_program_analysis)
26
+ tool for [Node.js](https://nodejs.org/) with a library of rules
27
+ to enforce standards and consistency for Markdown files. It was
28
+ inspired by - and heavily influenced by - Mark Harrison's
29
+ [markdownlint](https://github.com/markdownlint/markdownlint) for
30
+ [Ruby](https://www.ruby-lang.org/). The initial rules, rule documentation,
31
+ and test cases came directly from that project.
32
+
33
+ ### Related
34
+
35
+ * CLI
36
+ * [markdownlint-cli command-line interface for Node.js](https://github.com/igorshubovych/markdownlint-cli)
37
+ * GitHub
38
+ * [GitHub Super-Linter Action](https://github.com/github/super-linter)
39
+ * [GitHub Actions problem matcher for markdownlint-cli](https://github.com/xt0rted/markdownlint-problem-matcher)
40
+ * Editor
41
+ * [vscode-markdownlint extension for VS Code](https://marketplace.visualstudio.com/items/DavidAnson.vscode-markdownlint)
42
+ * [Sublime Text markdownlint for Sublime Text](https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint)
43
+ * [linter-node-markdownlint extension for Atom](https://atom.io/packages/linter-node-markdownlint)
44
+ * [coc-markdownlint extension for Vim/Neovim](https://github.com/fannheyward/coc-markdownlint)
45
+ * Tooling
46
+ * [grunt-markdownlint for the Grunt task runner](https://github.com/sagiegurari/grunt-markdownlint)
47
+ * [Cake.Markdownlint addin for Cake build automation system](https://github.com/cake-contrib/Cake.Markdownlint)
48
+ * Ruby
49
+ * [markdownlint/mdl gem for Ruby](https://rubygems.org/gems/mdl)
50
+
51
+ ## Demonstration
52
+
53
+ [`markdownlint` demo](https://dlaa.me/markdownlint/), an interactive, in-browser
54
+ playground for learning and exploring.
55
+
56
+ ## Rules / Aliases
57
+
58
+ * **[MD001](doc/Rules.md#md001)** *heading-increment/header-increment* - Heading levels should only increment by one level at a time
59
+ * ~~**[MD002](doc/Rules.md#md002)** *first-heading-h1/first-header-h1* - First heading should be a top level heading~~
60
+ * **[MD003](doc/Rules.md#md003)** *heading-style/header-style* - Heading style
61
+ * **[MD004](doc/Rules.md#md004)** *ul-style* - Unordered list style
62
+ * **[MD005](doc/Rules.md#md005)** *list-indent* - Inconsistent indentation for list items at the same level
63
+ * ~~**[MD006](doc/Rules.md#md006)** *ul-start-left* - Consider starting bulleted lists at the beginning of the line~~
64
+ * **[MD007](doc/Rules.md#md007)** *ul-indent* - Unordered list indentation
65
+ * **[MD009](doc/Rules.md#md009)** *no-trailing-spaces* - Trailing spaces
66
+ * **[MD010](doc/Rules.md#md010)** *no-hard-tabs* - Hard tabs
67
+ * **[MD011](doc/Rules.md#md011)** *no-reversed-links* - Reversed link syntax
68
+ * **[MD012](doc/Rules.md#md012)** *no-multiple-blanks* - Multiple consecutive blank lines
69
+ * **[MD013](doc/Rules.md#md013)** *line-length* - Line length
70
+ * **[MD014](doc/Rules.md#md014)** *commands-show-output* - Dollar signs used before commands without showing output
71
+ * **[MD018](doc/Rules.md#md018)** *no-missing-space-atx* - No space after hash on atx style heading
72
+ * **[MD019](doc/Rules.md#md019)** *no-multiple-space-atx* - Multiple spaces after hash on atx style heading
73
+ * **[MD020](doc/Rules.md#md020)** *no-missing-space-closed-atx* - No space inside hashes on closed atx style heading
74
+ * **[MD021](doc/Rules.md#md021)** *no-multiple-space-closed-atx* - Multiple spaces inside hashes on closed atx style heading
75
+ * **[MD022](doc/Rules.md#md022)** *blanks-around-headings/blanks-around-headers* - Headings should be surrounded by blank lines
76
+ * **[MD023](doc/Rules.md#md023)** *heading-start-left/header-start-left* - Headings must start at the beginning of the line
77
+ * **[MD024](doc/Rules.md#md024)** *no-duplicate-heading/no-duplicate-header* - Multiple headings with the same content
78
+ * **[MD025](doc/Rules.md#md025)** *single-title/single-h1* - Multiple top level headings in the same document
79
+ * **[MD026](doc/Rules.md#md026)** *no-trailing-punctuation* - Trailing punctuation in heading
80
+ * **[MD027](doc/Rules.md#md027)** *no-multiple-space-blockquote* - Multiple spaces after blockquote symbol
81
+ * **[MD028](doc/Rules.md#md028)** *no-blanks-blockquote* - Blank line inside blockquote
82
+ * **[MD029](doc/Rules.md#md029)** *ol-prefix* - Ordered list item prefix
83
+ * **[MD030](doc/Rules.md#md030)** *list-marker-space* - Spaces after list markers
84
+ * **[MD031](doc/Rules.md#md031)** *blanks-around-fences* - Fenced code blocks should be surrounded by blank lines
85
+ * **[MD032](doc/Rules.md#md032)** *blanks-around-lists* - Lists should be surrounded by blank lines
86
+ * **[MD033](doc/Rules.md#md033)** *no-inline-html* - Inline HTML
87
+ * **[MD034](doc/Rules.md#md034)** *no-bare-urls* - Bare URL used
88
+ * **[MD035](doc/Rules.md#md035)** *hr-style* - Horizontal rule style
89
+ * **[MD036](doc/Rules.md#md036)** *no-emphasis-as-heading/no-emphasis-as-header* - Emphasis used instead of a heading
90
+ * **[MD037](doc/Rules.md#md037)** *no-space-in-emphasis* - Spaces inside emphasis markers
91
+ * **[MD038](doc/Rules.md#md038)** *no-space-in-code* - Spaces inside code span elements
92
+ * **[MD039](doc/Rules.md#md039)** *no-space-in-links* - Spaces inside link text
93
+ * **[MD040](doc/Rules.md#md040)** *fenced-code-language* - Fenced code blocks should have a language specified
94
+ * **[MD041](doc/Rules.md#md041)** *first-line-heading/first-line-h1* - First line in file should be a top level heading
95
+ * **[MD042](doc/Rules.md#md042)** *no-empty-links* - No empty links
96
+ * **[MD043](doc/Rules.md#md043)** *required-headings/required-headers* - Required heading structure
97
+ * **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
98
+ * **[MD045](doc/Rules.md#md045)** *no-alt-text* - Images should have alternate text (alt text)
99
+ * **[MD046](doc/Rules.md#md046)** *code-block-style* - Code block style
100
+ * **[MD047](doc/Rules.md#md047)** *single-trailing-newline* - Files should end with a single newline character
101
+ * **[MD048](doc/Rules.md#md048)** *code-fence-style* - Code fence style
102
+
103
+ See [Rules.md](doc/Rules.md) for more details.
104
+
105
+ ~~Struck through~~ rules are deprecated, and provided for backward-compatibility.
106
+
107
+ > All rules with `heading` as part of their name are also available as `header`
108
+ > aliases (e.g. `heading-increment` is also available as `header-increment`).
109
+ > The use of `header` is deprecated and provided for backward-compatibility.
110
+
111
+ ## Tags
112
+
113
+ Tags group related rules and can be used to enable/disable multiple rules at once.
114
+
115
+ * **accessibility** - MD045
116
+ * **atx** - MD018, MD019
117
+ * **atx_closed** - MD020, MD021
118
+ * **blank_lines** - MD012, MD022, MD031, MD032, MD047
119
+ * **blockquote** - MD027, MD028
120
+ * **bullet** - MD004, MD005, MD006, MD007, MD032
121
+ * **code** - MD014, MD031, MD038, MD040, MD046, MD048
122
+ * **emphasis** - MD036, MD037
123
+ * **hard_tab** - MD010
124
+ * **headers** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023,
125
+ MD024, MD025, MD026, MD036, MD041, MD043
126
+ * **headings** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023,
127
+ MD024, MD025, MD026, MD036, MD041, MD043
128
+ * **hr** - MD035
129
+ * **html** - MD033
130
+ * **images** - MD045
131
+ * **indentation** - MD005, MD006, MD007, MD027
132
+ * **language** - MD040
133
+ * **line_length** - MD013
134
+ * **links** - MD011, MD034, MD039, MD042
135
+ * **ol** - MD029, MD030, MD032
136
+ * **spaces** - MD018, MD019, MD020, MD021, MD023
137
+ * **spelling** - MD044
138
+ * **ul** - MD004, MD005, MD006, MD007, MD030, MD032
139
+ * **url** - MD034
140
+ * **whitespace** - MD009, MD010, MD012, MD027, MD028, MD030, MD037, MD038, MD039
141
+
142
+ ## Configuration
143
+
144
+ Text passed to `markdownlint` is parsed as Markdown, analyzed, and any issues reported.
145
+ Two kinds of text are ignored:
146
+
147
+ * [HTML comments](https://www.w3.org/TR/html5/syntax.html#comments)
148
+ * [Front matter](https://jekyllrb.com/docs/frontmatter/) (see `options.frontMatter` below)
149
+
150
+ Rules can be enabled, disabled, and configured via `options.config` (described
151
+ below) to define the expected behavior for a set of inputs. To enable or disable
152
+ rules at a particular location within a file, add one of these markers to the
153
+ appropriate place (HTML comments don't appear in the final markup):
154
+
155
+ * Disable all rules: `<!-- markdownlint-disable -->`
156
+ * Enable all rules: `<!-- markdownlint-enable -->`
157
+ * Disable one or more rules by name: `<!-- markdownlint-disable MD001 MD005 -->`
158
+ * Enable one or more rules by name: `<!-- markdownlint-enable MD001 MD005 -->`
159
+ * Capture the current rule configuration: `<!-- markdownlint-capture -->`
160
+ * Restore the captured rule configuration: `<!-- markdownlint-restore -->`
161
+
162
+ For example:
163
+
164
+ ```markdown
165
+ <!-- markdownlint-disable no-space-in-emphasis -->
166
+ deliberate space * in * emphasis
167
+ <!-- markdownlint-enable no-space-in-emphasis -->
168
+ ```
169
+
170
+ To temporarily disable rule(s), then restore the former configuration:
171
+
172
+ ```markdown
173
+ <!-- markdownlint-capture -->
174
+ <!-- markdownlint-disable -->
175
+ any violations you want
176
+ <!-- markdownlint-restore -->
177
+ ```
178
+
179
+ The initial configuration is captured by default (as if every document began
180
+ with `<!-- markdownlint-capture -->`), so the pattern above can be expressed
181
+ more simply:
182
+
183
+ ```markdown
184
+ <!-- markdownlint-disable -->
185
+ any violations you want
186
+ <!-- markdownlint-restore -->
187
+ ```
188
+
189
+ Changes take effect starting with the line a comment is on, so the following
190
+ has no effect:
191
+
192
+ ```markdown
193
+ space * in * emphasis <!-- markdownlint-disable --> <!-- markdownlint-enable -->
194
+ ```
195
+
196
+ To apply changes to an entire file regardless of where the comment is located,
197
+ the following syntax is supported:
198
+
199
+ * Disable all rules: `<!-- markdownlint-disable-file -->`
200
+ * Enable all rules: `<!-- markdownlint-enable-file -->`
201
+ * Disable one or more rules by name: `<!-- markdownlint-disable-file MD001 -->`
202
+ * Enable one or more rules by name: `<!-- markdownlint-enable-file MD001 -->`
203
+
204
+ This can be used to "hide" `markdownlint` comments at the bottom of a file.
205
+
206
+ In cases where it is desirable to change the configuration of one or more rules
207
+ for a file, the following more advanced syntax is supported:
208
+
209
+ * Configure: `<!-- markdownlint-configure-file { options.config JSON } -->`
210
+
211
+ For example:
212
+
213
+ ```markdown
214
+ <!-- markdownlint-configure-file { "MD013": { "line_length": 70 } } -->
215
+ ```
216
+
217
+ or
218
+
219
+ ```markdown
220
+ <!-- markdownlint-configure-file
221
+ {
222
+ "hr-style": {
223
+ "style": "---"
224
+ },
225
+ "no-trailing-spaces": false
226
+ }
227
+ -->
228
+ ```
229
+
230
+ These changes apply to the entire file regardless of where the comment is
231
+ located. Multiple such comments (if present) are applied top-to-bottom.
232
+
233
+ ## API
234
+
235
+ ### Linting
236
+
237
+ Standard asynchronous interface:
238
+
239
+ ```js
240
+ /**
241
+ * Lint specified Markdown files.
242
+ *
243
+ * @param {Object} options Configuration options.
244
+ * @param {Function} callback Callback (err, result) function.
245
+ * @returns {void}
246
+ */
247
+ function markdownlint(options, callback) { ... }
248
+ ```
249
+
250
+ Synchronous interface (for build scripts, etc.):
251
+
252
+ ```js
253
+ /**
254
+ * Lint specified Markdown files synchronously.
255
+ *
256
+ * @param {Object} options Configuration options.
257
+ * @returns {Object} Result object.
258
+ */
259
+ function markdownlint.sync(options) { ... }
260
+ ```
261
+
262
+ #### options
263
+
264
+ Type: `Object`
265
+
266
+ Configures the function.
267
+
268
+ ##### options.customRules
269
+
270
+ Type: `Array` of `Object`
271
+
272
+ List of custom rules to include with the default rule set for linting.
273
+
274
+ Each array element should define a rule. Rules are typically exported by another
275
+ package, but can be defined inline.
276
+
277
+ Example:
278
+
279
+ ```js
280
+ const extraRules = require("extraRules");
281
+ const options = {
282
+ "customRules": [ extraRules.one, extraRules.two ]
283
+ };
284
+ ```
285
+
286
+ See [CustomRules.md](doc/CustomRules.md) for details about authoring custom rules.
287
+
288
+ ##### options.files
289
+
290
+ Type: `Array` of `String`
291
+
292
+ List of files to lint.
293
+
294
+ Each array element should be a single file (via relative or absolute path);
295
+ [globbing](https://en.wikipedia.org/wiki/Glob_%28programming%29) is the caller's
296
+ responsibility.
297
+
298
+ Example: `[ "one.md", "dir/two.md" ]`
299
+
300
+ ##### options.strings
301
+
302
+ Type: `Object` mapping `String` to `String`
303
+
304
+ Map of identifiers to strings for linting.
305
+
306
+ When Markdown content is not available as files, it can be passed as strings.
307
+ The keys of the `strings` object are used to identify each input value in the
308
+ `result` summary.
309
+
310
+ Example:
311
+
312
+ ```json
313
+ {
314
+ "readme": "# README\n...",
315
+ "changelog": "# CHANGELOG\n..."
316
+ }
317
+ ```
318
+
319
+ ##### options.config
320
+
321
+ Type: `Object` mapping `String` to `Boolean | Object`
322
+
323
+ Configures the rules to use.
324
+
325
+ Object keys are rule names or aliases and values are the rule's configuration.
326
+ The value `false` disables a rule, `true` enables its default configuration,
327
+ and passing an object customizes its settings. Setting the special `default`
328
+ rule to `true` or `false` includes/excludes all rules by default. Enabling or
329
+ disabling a tag name (ex: `whitespace`) affects all rules having that tag.
330
+
331
+ The `default` rule is applied first, then keys are processed in order from top
332
+ to bottom with later values overriding earlier ones. Keys (including rule names,
333
+ aliases, tags, and `default`) are not case-sensitive.
334
+
335
+ Example:
336
+
337
+ ```json
338
+ {
339
+ "default": true,
340
+ "MD003": { "style": "atx_closed" },
341
+ "MD007": { "indent": 4 },
342
+ "no-hard-tabs": false,
343
+ "whitespace": false
344
+ }
345
+ ```
346
+
347
+ Sets of rules (known as a "style") can be stored separately and loaded as
348
+ [JSON](https://en.wikipedia.org/wiki/JSON).
349
+
350
+ Example:
351
+
352
+ ```js
353
+ const options = {
354
+ "files": [ "..." ],
355
+ "config": require("style/relaxed.json")
356
+ };
357
+ ```
358
+
359
+ See the [style](style) directory for more samples.
360
+
361
+ See [markdownlint-config-schema.json](schema/markdownlint-config-schema.json)
362
+ for the [JSON Schema](https://json-schema.org/) of the `options.config` object.
363
+
364
+ For more advanced scenarios, styles can reference and extend other styles. The
365
+ `readConfig` and `readConfigSync` functions can be used to read such styles.
366
+
367
+ For example, assuming a `base.json` configuration file:
368
+
369
+ ```json
370
+ {
371
+ "default": true
372
+ }
373
+ ```
374
+
375
+ And a `custom.json` configuration file:
376
+
377
+ ```json
378
+ {
379
+ "extends": "base.json",
380
+ "line-length": false
381
+ }
382
+ ```
383
+
384
+ Then code like the following:
385
+
386
+ ```js
387
+ const options = {
388
+ "config": markdownlint.readConfigSync("./custom.json")
389
+ };
390
+ ```
391
+
392
+ Merges `custom.json` and `base.json` and is equivalent to:
393
+
394
+ ```js
395
+ const options = {
396
+ "config": {
397
+ "default": true,
398
+ "line-length": false
399
+ }
400
+ };
401
+ ```
402
+
403
+ ##### options.frontMatter
404
+
405
+ Type: `RegExp`
406
+
407
+ Matches any [front matter](https://jekyllrb.com/docs/frontmatter/) found at the
408
+ beginning of a file.
409
+
410
+ Some Markdown content begins with metadata; the default `RegExp` for this option
411
+ ignores common forms of "front matter". To match differently, specify a custom
412
+ `RegExp` or use the value `null` to disable the feature.
413
+
414
+ The default value:
415
+
416
+ ```js
417
+ /((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m
418
+ ```
419
+
420
+ Ignores [YAML](https://en.wikipedia.org/wiki/YAML) and
421
+ [TOML](https://en.wikipedia.org/wiki/TOML) such as:
422
+
423
+ ```text
424
+ ---
425
+ layout: post
426
+ title: Title
427
+ ---
428
+ ```
429
+
430
+ Note: Matches must occur at the start of the file.
431
+
432
+ ##### options.handleRuleFailures
433
+
434
+ Type: `Boolean`
435
+
436
+ Catches exceptions thrown during rule processing and reports the problem as a
437
+ rule violation.
438
+
439
+ By default, exceptions thrown by rules (or the library itself) are unhandled
440
+ and bubble up the stack to the caller in the conventional manner. By setting
441
+ `handleRuleFailures` to `true`, exceptions thrown by failing rules will be
442
+ handled by the library and the exception message logged as a rule violation.
443
+ This setting can be useful in the presence of (custom) rules that encounter
444
+ unexpected syntax and fail. By enabling this option, the linting process is
445
+ allowed to continue and report any violations that were found.
446
+
447
+ ##### options.noInlineConfig
448
+
449
+ Type: `Boolean`
450
+
451
+ Disables the use of HTML comments like `<!-- markdownlint-disable -->` to toggle
452
+ rules within the body of Markdown content.
453
+
454
+ By default, properly-formatted inline comments can be used to create exceptions
455
+ for parts of a document. Setting `noInlineConfig` to `true` ignores all such
456
+ comments.
457
+
458
+ ##### options.resultVersion
459
+
460
+ Type: `Number`
461
+
462
+ Specifies which version of the `result` object to return (see the "Usage" section
463
+ below for examples).
464
+
465
+ Passing a `resultVersion` of `0` corresponds to the original, simple format where
466
+ each error is identified by rule name and line number. *This is deprecated.*
467
+
468
+ Passing a `resultVersion` of `1` corresponds to a detailed format where each error
469
+ includes information about the line number, rule name, alias, description, as well
470
+ as any additional detail or context that is available. *This is deprecated.*
471
+
472
+ Passing a `resultVersion` of `2` corresponds to a detailed format where each error
473
+ includes information about the line number, rule names, description, as well as any
474
+ additional detail or context that is available. *This is the default.*
475
+
476
+ Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
477
+ with additional information about how to fix automatically-fixable errors. In this
478
+ mode, all errors that occur on each line are reported (other versions report only
479
+ the first error for each rule).
480
+
481
+ ##### options.markdownItPlugins
482
+
483
+ Type: `Array` of `Array` of `Function` and plugin parameters
484
+
485
+ Specifies additional [markdown-it plugins](https://www.npmjs.com/search?q=keywords:markdown-it-plugin)
486
+ to use when parsing input. Plugins can be used to support additional syntax and
487
+ features for advanced scenarios.
488
+
489
+ Each item in the top-level `Array` should be of the form:
490
+
491
+ ```js
492
+ [ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
493
+ ```
494
+
495
+ #### callback
496
+
497
+ Type: `Function` taking (`Error`, `Object`)
498
+
499
+ Standard completion callback.
500
+
501
+ #### result
502
+
503
+ Type: `Object`
504
+
505
+ Call `result.toString()` for convenience or see below for an example of the
506
+ structure of the `result` object. Passing the value `true` to `toString()`
507
+ uses rule aliases (ex: `no-hard-tabs`) instead of names (ex: `MD010`).
508
+
509
+ ### Config
510
+
511
+ The `options.config` configuration object is simple and can be stored in a file
512
+ for readability and easy reuse. The `readConfig` and `readConfigSync` functions
513
+ load configuration settings and support the `extends` keyword for referencing
514
+ other files (see above).
515
+
516
+ By default, configuration files are parsed as JSON (and named `.markdownlint.json`).
517
+ Custom parsers can be provided to handle other formats like JSONC, YAML, and TOML.
518
+
519
+ Asynchronous interface:
520
+
521
+ ```js
522
+ /**
523
+ * Read specified configuration file.
524
+ *
525
+ * @param {String} file Configuration file name/path.
526
+ * @param {Array} [parsers] Optional parsing function(s).
527
+ * @param {Function} callback Callback (err, result) function.
528
+ * @returns {void}
529
+ */
530
+ function readConfig(file, parsers, callback) { ... }
531
+ ```
532
+
533
+ Synchronous interface:
534
+
535
+ ```js
536
+ /**
537
+ * Read specified configuration file synchronously.
538
+ *
539
+ * @param {String} file Configuration file name/path.
540
+ * @param {Array} [parsers] Optional parsing function(s).
541
+ * @returns {Object} Configuration object.
542
+ */
543
+ function readConfigSync(file, parsers) { ... }
544
+ ```
545
+
546
+ #### file
547
+
548
+ Type: `String`
549
+
550
+ Location of configuration file to read.
551
+
552
+ The `file` is resolved relative to the current working directory. If an `extends`
553
+ key is present once read, its value will be resolved as a path relative to `file`
554
+ and loaded recursively. Settings from a file referenced by `extends` are applied
555
+ first, then those of `file` are applied on top (overriding any of the same keys
556
+ appearing in the referenced file).
557
+
558
+ #### parsers
559
+
560
+ Type: *Optional* `Array` of `Function` taking (`String`) and returning `Object`
561
+
562
+ Array of functions to parse configuration files.
563
+
564
+ The contents of a configuration file are passed to each parser function until one
565
+ of them returns a value (vs. throwing an exception). Consequently, strict parsers
566
+ should come before flexible parsers.
567
+
568
+ For example:
569
+
570
+ ```js
571
+ [ JSON.parse, require("toml").parse, require("js-yaml").safeLoad ]
572
+ ```
573
+
574
+ #### callback
575
+
576
+ Type: `Function` taking (`Error`, `Object`)
577
+
578
+ Standard completion callback.
579
+
580
+ #### result
581
+
582
+ Type: `Object`
583
+
584
+ Configuration object.
585
+
586
+ ## Usage
587
+
588
+ Invoke `markdownlint` and use the `result` object's `toString` method:
589
+
590
+ ```js
591
+ const markdownlint = require("markdownlint");
592
+
593
+ const options = {
594
+ "files": [ "good.md", "bad.md" ],
595
+ "strings": {
596
+ "good.string": "# good.string\n\nThis string passes all rules.",
597
+ "bad.string": "#bad.string\n\n#This string fails\tsome rules."
598
+ }
599
+ };
600
+
601
+ markdownlint(options, function callback(err, result) {
602
+ if (!err) {
603
+ console.log(result.toString());
604
+ }
605
+ });
606
+ ```
607
+
608
+ Output:
609
+
610
+ ```text
611
+ bad.string: 3: MD010/no-hard-tabs Hard tabs [Column: 19]
612
+ bad.string: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.string"]
613
+ bad.string: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This string fails some rules."]
614
+ bad.string: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.string"]
615
+ bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
616
+ bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
617
+ bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
618
+ bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
619
+ ```
620
+
621
+ Or invoke `markdownlint.sync` for a synchronous call:
622
+
623
+ ```js
624
+ const result = markdownlint.sync(options);
625
+ console.log(result.toString());
626
+ ```
627
+
628
+ To examine the `result` object directly:
629
+
630
+ ```js
631
+ markdownlint(options, function callback(err, result) {
632
+ if (!err) {
633
+ console.dir(result, { "colors": true, "depth": null });
634
+ }
635
+ });
636
+ ```
637
+
638
+ Output:
639
+
640
+ ```json
641
+ {
642
+ "good.md": [],
643
+ "bad.md": [
644
+ { "lineNumber": 3,
645
+ "ruleNames": [ "MD010", "no-hard-tabs" ],
646
+ "ruleDescription": "Hard tabs",
647
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
648
+ "errorDetail": "Column: 17",
649
+ "errorContext": null,
650
+ "errorRange": [ 17, 1 ] },
651
+ { "lineNumber": 1,
652
+ "ruleNames": [ "MD018", "no-missing-space-atx" ],
653
+ "ruleDescription": "No space after hash on atx style heading",
654
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
655
+ "errorDetail": null,
656
+ "errorContext": "#bad.md",
657
+ "errorRange": [ 1, 2 ] },
658
+ { "lineNumber": 3,
659
+ "ruleNames": [ "MD018", "no-missing-space-atx" ],
660
+ "ruleDescription": "No space after hash on atx style heading",
661
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
662
+ "errorDetail": null,
663
+ "errorContext": "#This file fails\tsome rules.",
664
+ "errorRange": [ 1, 2 ] },
665
+ { "lineNumber": 1,
666
+ "ruleNames": [ "MD041", "first-line-heading", "first-line-h1" ],
667
+ "ruleDescription": "First line in file should be a top level heading",
668
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md041",
669
+ "errorDetail": null,
670
+ "errorContext": "#bad.md",
671
+ "errorRange": null }
672
+ ]
673
+ }
674
+ ```
675
+
676
+ Integration with the [gulp](https://gulpjs.com/) build system is straightforward:
677
+
678
+ ```js
679
+ const gulp = require("gulp");
680
+ const through2 = require("through2");
681
+ const markdownlint = require("markdownlint");
682
+
683
+ gulp.task("markdownlint", function task() {
684
+ return gulp.src("*.md", { "read": false })
685
+ .pipe(through2.obj(function obj(file, enc, next) {
686
+ markdownlint(
687
+ { "files": [ file.relative ] },
688
+ function callback(err, result) {
689
+ const resultString = (result || "").toString();
690
+ if (resultString) {
691
+ console.log(resultString);
692
+ }
693
+ next(err, file);
694
+ });
695
+ }));
696
+ });
697
+ ```
698
+
699
+ Output:
700
+
701
+ ```text
702
+ [00:00:00] Starting 'markdownlint'...
703
+ bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
704
+ bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
705
+ bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
706
+ bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
707
+ [00:00:00] Finished 'markdownlint' after 10 ms
708
+ ```
709
+
710
+ Integration with the [Grunt](https://gruntjs.com/) build system is similar:
711
+
712
+ ```js
713
+ const markdownlint = require("markdownlint");
714
+
715
+ module.exports = function wrapper(grunt) {
716
+ grunt.initConfig({
717
+ "markdownlint": {
718
+ "example": {
719
+ "src": [ "*.md" ]
720
+ }
721
+ }
722
+ });
723
+
724
+ grunt.registerMultiTask("markdownlint", function task() {
725
+ const done = this.async();
726
+ markdownlint(
727
+ { "files": this.filesSrc },
728
+ function callback(err, result) {
729
+ const resultString = err || ((result || "").toString());
730
+ if (resultString) {
731
+ grunt.fail.warn("\n" + resultString + "\n");
732
+ }
733
+ done(!err || !resultString);
734
+ });
735
+ });
736
+ };
737
+ ```
738
+
739
+ Output:
740
+
741
+ ```text
742
+ Running "markdownlint:example" (markdownlint) task
743
+ Warning:
744
+ bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
745
+ bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
746
+ bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
747
+ bad.md: 1: MD041/first-line-heading/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
748
+ Use --force to continue.
749
+ ```
750
+
751
+ ## Browser
752
+
753
+ `markdownlint` also works in the browser.
754
+
755
+ Generate normal and minified scripts with:
756
+
757
+ ```shell
758
+ npm run build-demo
759
+ ```
760
+
761
+ Then reference `markdown-it` and `markdownlint`:
762
+
763
+ ```html
764
+ <script src="demo/markdown-it.min.js"></script>
765
+ <script src="demo/markdownlint-browser.min.js"></script>
766
+ ```
767
+
768
+ And call it like so:
769
+
770
+ ```js
771
+ const options = {
772
+ "strings": {
773
+ "content": "Some Markdown to lint."
774
+ }
775
+ };
776
+ const results = window.markdownlint.sync(options).toString();
777
+ ```
778
+
779
+ ## Examples
780
+
781
+ For ideas how to integrate `markdownlint` into your workflow, refer to the following projects:
782
+
783
+ * [.NET Documentation](https://docs.microsoft.com/en-us/dotnet/) ([Search repository](https://github.com/dotnet/docs/search?q=markdownlint))
784
+ * [ally.js](https://allyjs.io/) ([Search repository](https://github.com/medialize/ally.js/search?q=markdownlint))
785
+ * [Boostnote](https://boostnote.io/) ([Search repository](https://github.com/BoostIO/Boostnote/search?q=markdownlint))
786
+ * [CodiMD](https://github.com/hackmdio/codimd) ([Search repository](https://github.com/hackmdio/codimd/search?q=markdownlint))
787
+ * [ESLint](https://eslint.org/) ([Search repository](https://github.com/eslint/eslint/search?q=markdownlint))
788
+ * [Garden React Components](https://garden.zendesk.com/react-components/) ([Search repository](https://github.com/zendeskgarden/react-components/search?q=markdownlint))
789
+ * [MkDocs](https://www.mkdocs.org/) ([Search repository](https://github.com/mkdocs/mkdocs/search?q=markdownlint))
790
+ * [Mocha](https://mochajs.org/) ([Search repository](https://github.com/mochajs/mocha/search?q=markdownlint))
791
+ * [Reactable](https://glittershark.github.io/reactable/) ([Search repository](https://github.com/glittershark/reactable/search?q=markdownlint))
792
+ * [Sinon.JS](https://sinonjs.org/) ([Search repository](https://github.com/sinonjs/sinon/search?q=markdownlint))
793
+ * [TestCafe](https://devexpress.github.io/testcafe/) ([Search repository](https://github.com/DevExpress/testcafe/search?q=markdownlint))
794
+ * [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html) ([Search repository](https://github.com/Microsoft/TypeScript-Handbook/search?q=markdownlint))
795
+ * [V8](https://v8.dev/) ([Search repository](https://github.com/v8/v8.dev/search?q=markdownlint))
796
+ * [webhint](https://webhint.io/) ([Search repository](https://github.com/webhintio/hint/search?q=markdownlint))
797
+ * [webpack](https://webpack.js.org/) ([Search repository](https://github.com/webpack/webpack.js.org/search?q=markdownlint))
798
+ * [WordPress](https://wordpress.org/gutenberg/) ([Search repository](https://github.com/WordPress/gutenberg/search?q=markdownlint))
799
+
800
+ ## Contributing
801
+
802
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
803
+
804
+ ## History
805
+
806
+ * 0.0.1 - Initial release, includes tests MD001-MD032.
807
+ * 0.0.2 - Improve documentation, tests, and code.
808
+ * 0.0.3 - Add synchronous API, improve documentation and code.
809
+ * 0.0.4 - Add tests MD033-MD040, update dependencies.
810
+ * 0.0.5 - Add `strings` option to enable file-less scenarios, add in-browser demo.
811
+ * 0.0.6 - Improve performance, simplify in-browser, update dependencies.
812
+ * 0.0.7 - Add MD041, improve MD003, ignore front matter, update dependencies.
813
+ * 0.0.8 - Support disabling/enabling rules inline, improve code fence, dependencies.
814
+ * 0.1.0 - Add aliases, exceptions for MD033, exclusions for MD013, dependencies.
815
+ * 0.1.1 - Fix bug handling HTML in tables, reference markdownlint-cli.
816
+ * 0.2.0 - Add MD042/MD043, enhance MD002/MD003/MD004/MD007/MD011/MD025/MD041, dependencies.
817
+ * 0.3.0 - More detailed error reporting with `resultVersion`, enhance MD010/MD012/MD036,
818
+ fixes for MD027/MD029/MD030, include JSON schema, dependencies.
819
+ * 0.3.1 - Fix regressions in MD032/MD038, update dependencies.
820
+ * 0.4.0 - Add MD044, enhance MD013/MD032/MD041/MD042/MD043, fix for MD038, dependencies.
821
+ * 0.4.1 - Fixes for MD038/front matter, improvements to MD044, update dependencies.
822
+ * 0.5.0 - Add shareable configuration, `noInlineConfig` option, README links, fix MD030,
823
+ improve MD009/MD041, update dependencies.
824
+ * 0.6.0 - `resultVersion` defaults to 1 (breaking change), ignore HTML comments, TOML
825
+ front matter, fixes for MD044, update dependencies.
826
+ * 0.6.1 - Update `markdown-it` versioning, exclude demo/test from publishing.
827
+ * 0.6.2 - Improve MD013/MD027/MD034/MD037/MD038/MD041/MD044, update dependencies.
828
+ * 0.6.3 - Improve highlighting for MD020.
829
+ * 0.6.4 - Improve MD029/MD042, update dependencies.
830
+ * 0.7.0 - `resultVersion` defaults to 2 (breaking change), add MD045, improve MD029,
831
+ remove trimLeft/trimRight, split rules, refactor, update dependencies.
832
+ * 0.8.0 - Add support for using and authoring custom rules, improve MD004/MD007/MD013,
833
+ add `engines` to `package.json`, refactor, update dependencies.
834
+ * 0.8.1 - Update item loop to be iterative, improve MD014, update dependencies.
835
+ * 0.9.0 - Remove support for end-of-life Node versions 0.10/0.12/4, change "header" to
836
+ "heading" per spec (non-breaking), improve MD003/MD009/MD041, handle uncommon
837
+ line-break characters, refactor for ES6, update dependencies.
838
+ * 0.10.0 - Add support for non-JSON configuration files, pass file/string name to custom
839
+ rules, update dependencies.
840
+ * 0.11.0 - Improve MD005/MD024/MD029/MD038, improve custom rule example, add CONTRIBUTING.md,
841
+ update dependencies.
842
+ * 0.12.0 - Add `information` link for custom rules, `markdownItPlugins` for extensibility,
843
+ improve MD023/MD032/MD038, update dependencies.
844
+ * 0.13.0 - Improve MD013/MD022/MD025/MD029/MD031/MD032/MD037/MD041/, deprecate MD002,
845
+ improve pandoc YAML support, update dependencies.
846
+ * 0.14.0 - Remove support for end-of-life Node version 6, introduce `markdownlint-rule-helpers`,
847
+ add MD046/MD047, improve MD033/MD034/MD039, improve custom rule validation and
848
+ in-browser demo, update dependencies.
849
+ * 0.14.1 - Improve MD033.
850
+ * 0.14.2 - Improve MD047, add `handleRuleFailures` option.
851
+ * 0.15.0 - Add `markdownlint-capture`/`markdownlint-restore` inline comments, improve
852
+ MD009/MD013/MD026/MD033/MD036, update dependencies.
853
+ * 0.16.0 - Add custom rule sample for linting code, improve MD026/MD031/MD033/MD038,
854
+ update dependencies.
855
+ * 0.17.0 - Add `resultVersion` 3 to support fix information for default and custom rules,
856
+ add fix information for 24 rules, update newline handling to match latest
857
+ CommonMark specification, improve MD014/MD037/MD039, update dependencies.
858
+ * 0.17.1 - Fix handling of front matter by fix information.
859
+ * 0.17.2 - Improve MD020/MD033/MD044.
860
+ * 0.18.0 - Add MD048/code-fence-style, add fix information for MD007/ul-indent, add
861
+ `markdownlint-disable-file`/`markdownlint-enable-file` inline comments, add
862
+ type declaration file (.d.ts) for TypeScript dependents, update schema, improve
863
+ MD006/MD007/MD009/MD013/MD030, update dependencies.
864
+ * 0.19.0 - Remove support for end-of-life Node version 8, add fix information for
865
+ MD005/list-indent, improve MD007/MD013/MD014, deprecate MD006/ul-start-left, add
866
+ rationale for every rule, update test runner and code coverage, add more JSDoc
867
+ comments, update dependencies.
868
+ * 0.20.0 - Add `markdownlint-configure-file` inline comment, reimplement MD037,
869
+ improve MD005/MD007/MD013/MD018/MD029/MD031/MD034/MD038/MD039, improve HTML
870
+ comment handling, update dependencies.
871
+ * 0.20.1 - Fix regression in MD037.
872
+ * 0.20.2 - Fix regression in MD037, improve MD038.
873
+ * 0.20.3 - Fix regression in MD037, improve MD044, add automatic regression testing.
874
+ * 0.20.4 - Fix regression in MD037, improve MD034/MD044, improve documentation.
875
+
876
+ [npm-image]: https://img.shields.io/npm/v/markdownlint.svg
877
+ [npm-url]: https://www.npmjs.com/package/markdownlint
878
+ [ci-image]: https://github.com/DavidAnson/markdownlint/workflows/CI/badge.svg?branch=master
879
+ [ci-url]: https://github.com/DavidAnson/markdownlint/actions?query=branch%3Amaster
880
+ [license-image]: https://img.shields.io/npm/l/markdownlint.svg
881
+ [license-url]: https://opensource.org/licenses/MIT