markdownlint 0.35.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +72 -35
- package/demo/markdownlint-browser.js +1259 -1215
- package/doc/CustomRules.md +55 -249
- package/doc/Rules.md +36 -29
- package/doc/md003.md +2 -2
- package/doc/md004.md +4 -3
- package/doc/md035.md +3 -8
- package/doc/md046.md +2 -2
- package/doc/md048.md +3 -2
- package/doc/md049.md +4 -3
- package/doc/md050.md +4 -4
- package/doc/md051.md +11 -3
- package/doc/md055.md +3 -2
- package/helpers/README.md +2 -19
- package/helpers/helpers.js +87 -347
- package/helpers/micromark-helpers.cjs +296 -0
- package/helpers/micromark-parse.cjs +313 -0
- package/helpers/package.json +5 -2
- package/helpers/shared.js +6 -0
- package/helpers/test.cjs +28 -0
- package/lib/cache.js +3 -3
- package/lib/configuration-strict.d.ts +120 -106
- package/lib/constants.js +1 -1
- package/lib/markdownit.cjs +172 -0
- package/lib/markdownlint.d.ts +41 -3
- package/lib/markdownlint.js +153 -115
- package/lib/md001.js +1 -1
- package/lib/md003.js +1 -1
- package/lib/md004.js +3 -3
- package/lib/md007.js +3 -3
- package/lib/md009.js +1 -1
- package/lib/md010.js +18 -14
- package/lib/md011.js +24 -23
- package/lib/md012.js +1 -1
- package/lib/md013.js +1 -1
- package/lib/md014.js +5 -9
- package/lib/md018.js +1 -1
- package/lib/md019-md021.js +1 -1
- package/lib/md020.js +2 -2
- package/lib/md022.js +9 -15
- package/lib/md024.js +1 -1
- package/lib/md025.js +1 -1
- package/lib/md027.js +2 -2
- package/lib/md029.js +3 -3
- package/lib/md031.js +8 -6
- package/lib/md032.js +27 -15
- package/lib/md033.js +1 -1
- package/lib/md034.js +21 -29
- package/lib/md036.js +18 -24
- package/lib/md037.js +1 -1
- package/lib/md038.js +9 -14
- package/lib/md039.js +13 -15
- package/lib/md040.js +11 -13
- package/lib/md041.js +4 -4
- package/lib/md042.js +2 -6
- package/lib/md043.js +1 -1
- package/lib/md044.js +31 -28
- package/lib/md045.js +2 -2
- package/lib/md048.js +28 -17
- package/lib/md049-md050.js +20 -5
- package/lib/md051.js +16 -18
- package/lib/md053.js +5 -4
- package/lib/md054.js +11 -13
- package/lib/md055.js +39 -46
- package/lib/md056.js +31 -36
- package/lib/md058.js +29 -14
- package/package.json +14 -13
- package/schema/.markdownlint.jsonc +55 -52
- package/schema/.markdownlint.yaml +54 -52
- package/schema/markdownlint-config-schema-strict.json +132 -110
- package/schema/markdownlint-config-schema.json +132 -110
- package/helpers/micromark.cjs +0 -544
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.36.1
|
|
4
|
+
|
|
5
|
+
- Fix behavior of MD054
|
|
6
|
+
|
|
7
|
+
## 0.36.0
|
|
8
|
+
|
|
9
|
+
- Improve MD051
|
|
10
|
+
- Move `applyFix` and `applyFixes` from helpers to core
|
|
11
|
+
- Make `micromark` parser available to custom rules
|
|
12
|
+
- Introduce `./micromark` helpers exports
|
|
13
|
+
- Update custom/rule documentation
|
|
14
|
+
- Improve performance
|
|
15
|
+
- Update dependencies
|
|
16
|
+
|
|
3
17
|
## 0.35.0
|
|
4
18
|
|
|
5
19
|
- Add MD058/blanks-around-tables
|
package/README.md
CHANGED
|
@@ -13,22 +13,31 @@ npm install markdownlint --save-dev
|
|
|
13
13
|
|
|
14
14
|
## Overview
|
|
15
15
|
|
|
16
|
-
The [Markdown]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
The [Markdown][markdown] markup language is designed to be easy to read, write,
|
|
17
|
+
and understand. It succeeds - and its flexibility is both a benefit and a
|
|
18
|
+
drawback. Many styles are possible, so formatting can be inconsistent; some
|
|
19
|
+
constructs don't work well in all parsers and should be avoided.
|
|
20
|
+
|
|
21
|
+
`markdownlint` is a [static analysis][static-analysis] tool for
|
|
22
|
+
[Node.js][nodejs] with a library of rules to enforce standards and consistency
|
|
23
|
+
for Markdown files. It was inspired by - and heavily influenced by - Mark
|
|
24
|
+
Harrison's [markdownlint][markdownlint-ruby] for Ruby. The initial rules, rule
|
|
25
|
+
documentation, and test cases came from that project.
|
|
26
|
+
|
|
27
|
+
`markdownlint` uses the [`micromark`][micromark] parser and honors the
|
|
28
|
+
[CommonMark][commonmark] specification for Markdown. It additionally supports
|
|
29
|
+
popular [GitHub Flavored Markdown (GFM)][gfm] syntax like autolinks and tables
|
|
30
|
+
as well as directives, footnotes, and math syntax - all implemented by
|
|
31
|
+
[`micromark` extensions][micromark-extensions].
|
|
32
|
+
|
|
33
|
+
[commonmark]: https://commonmark.org/
|
|
34
|
+
[gfm]: https://github.github.com/gfm/
|
|
35
|
+
[markdown]: https://en.wikipedia.org/wiki/Markdown
|
|
36
|
+
[markdownlint-ruby]: https://github.com/markdownlint/markdownlint
|
|
37
|
+
[micromark]: https://github.com/micromark/micromark
|
|
38
|
+
[micromark-extensions]: https://github.com/micromark/micromark?tab=readme-ov-file#list-of-extensions
|
|
39
|
+
[nodejs]: https://nodejs.org/
|
|
40
|
+
[static-analysis]: https://en.wikipedia.org/wiki/Static_program_analysis
|
|
32
41
|
|
|
33
42
|
### Related
|
|
34
43
|
|
|
@@ -516,7 +525,7 @@ specify a custom `RegExp` or use the value `null` to disable the feature.
|
|
|
516
525
|
The default value:
|
|
517
526
|
|
|
518
527
|
```javascript
|
|
519
|
-
/((
|
|
528
|
+
/((^---[^\S\r\n\u2028\u2029]*$[\s\S]+?^---\s*)|(^\+\+\+[^\S\r\n\u2028\u2029]*$[\s\S]+?^(\+\+\+|\.\.\.)\s*)|(^\{[^\S\r\n\u2028\u2029]*$[\s\S]+?^\}\s*))(\r\n|\r|\n|$)/m
|
|
520
529
|
```
|
|
521
530
|
|
|
522
531
|
Ignores [YAML](https://en.wikipedia.org/wiki/YAML),
|
|
@@ -565,7 +574,7 @@ Type: `Array` of `Array` of `Function` and plugin parameters
|
|
|
565
574
|
|
|
566
575
|
Specifies additional [`markdown-it` plugins][markdown-it-plugin] to use when
|
|
567
576
|
parsing input. Plugins can be used to support additional syntax and features for
|
|
568
|
-
advanced scenarios.
|
|
577
|
+
advanced scenarios. *Deprecated.*
|
|
569
578
|
|
|
570
579
|
[markdown-it-plugin]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
|
|
571
580
|
|
|
@@ -601,23 +610,20 @@ Specifies which version of the `result` object to return (see the "Usage"
|
|
|
601
610
|
section below for examples).
|
|
602
611
|
|
|
603
612
|
Passing a `resultVersion` of `0` corresponds to the original, simple format
|
|
604
|
-
where each error is identified by rule name and line number. *
|
|
605
|
-
deprecated.*
|
|
613
|
+
where each error is identified by rule name and line number. *Deprecated*
|
|
606
614
|
|
|
607
615
|
Passing a `resultVersion` of `1` corresponds to a detailed format where each
|
|
608
616
|
error includes information about the line number, rule name, alias, description,
|
|
609
|
-
as well as any additional detail or context that is available. *
|
|
610
|
-
deprecated.*
|
|
617
|
+
as well as any additional detail or context that is available. *Deprecated*
|
|
611
618
|
|
|
612
619
|
Passing a `resultVersion` of `2` corresponds to a detailed format where each
|
|
613
620
|
error includes information about the line number, rule names, description, as
|
|
614
|
-
well as any additional detail or context that is available. *
|
|
615
|
-
deprecated.*
|
|
621
|
+
well as any additional detail or context that is available. *Deprecated*
|
|
616
622
|
|
|
617
623
|
Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
|
|
618
624
|
with additional information about how to fix automatically-fixable errors. In
|
|
619
625
|
this mode, all errors that occur on each line are reported (other versions
|
|
620
|
-
report only the first error for each rule).
|
|
626
|
+
report only the first error for each rule). This is the default behavior.
|
|
621
627
|
|
|
622
628
|
##### options.strings
|
|
623
629
|
|
|
@@ -762,6 +768,44 @@ Type: `Object`
|
|
|
762
768
|
|
|
763
769
|
Configuration object.
|
|
764
770
|
|
|
771
|
+
### Fixing
|
|
772
|
+
|
|
773
|
+
Rules that can be fixed automatically include a `fixInfo` property which is
|
|
774
|
+
outlined in the [documentation for custom rules](doc/CustomRules.md#authoring).
|
|
775
|
+
To apply fixes consistently, the `applyFix`/`applyFixes` methods may be used:
|
|
776
|
+
|
|
777
|
+
```javascript
|
|
778
|
+
/**
|
|
779
|
+
* Applies the specified fix to a Markdown content line.
|
|
780
|
+
*
|
|
781
|
+
* @param {string} line Line of Markdown content.
|
|
782
|
+
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
|
|
783
|
+
* @param {string} [lineEnding] Line ending to use.
|
|
784
|
+
* @returns {string | null} Fixed content or null if deleted.
|
|
785
|
+
*/
|
|
786
|
+
function applyFix(line, fixInfo, lineEnding = "\n") { ... }
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Applies as many of the specified fixes as possible to Markdown content.
|
|
790
|
+
*
|
|
791
|
+
* @param {string} input Lines of Markdown content.
|
|
792
|
+
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
|
793
|
+
* @returns {string} Fixed content.
|
|
794
|
+
*/
|
|
795
|
+
function applyFixes(input, errors) { ... }
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
Invoking `applyFixes` with the results of a call to lint can be done like so:
|
|
799
|
+
|
|
800
|
+
```javascript
|
|
801
|
+
const { "sync": markdownlintSync, applyFixes } = require("markdownlint");
|
|
802
|
+
|
|
803
|
+
function fixMarkdownlintViolations(content) {
|
|
804
|
+
const fixResults = markdownlintSync({ strings: { content } });
|
|
805
|
+
return applyFixes(content, fixResults.content);
|
|
806
|
+
}
|
|
807
|
+
```
|
|
808
|
+
|
|
765
809
|
## Usage
|
|
766
810
|
|
|
767
811
|
Invoke `markdownlint` and use the `result` object's `toString` method:
|
|
@@ -928,14 +972,6 @@ bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be
|
|
|
928
972
|
Use --force to continue.
|
|
929
973
|
```
|
|
930
974
|
|
|
931
|
-
### Fixing
|
|
932
|
-
|
|
933
|
-
Rules that can be fixed automatically include a `fixInfo` property which is
|
|
934
|
-
outlined in the [documentation for custom rules](doc/CustomRules.md#authoring).
|
|
935
|
-
To apply those fixes more easily, the `applyFixes` method in
|
|
936
|
-
[markdownlint-rule-helpers](helpers/README.md#applying-recommended-fixes) may
|
|
937
|
-
be used.
|
|
938
|
-
|
|
939
975
|
## Browser
|
|
940
976
|
|
|
941
977
|
`markdownlint` also works in the browser.
|
|
@@ -946,10 +982,11 @@ Generate normal and minified scripts with:
|
|
|
946
982
|
npm run build-demo
|
|
947
983
|
```
|
|
948
984
|
|
|
949
|
-
Then reference `
|
|
985
|
+
Then reference `markdownlint` and `micromark` scripts:
|
|
950
986
|
|
|
951
987
|
```html
|
|
952
|
-
<script src="demo/
|
|
988
|
+
<script src="demo/micromark-browser.js"></script>
|
|
989
|
+
<script src="demo/micromark-html-browser.js"></script>
|
|
953
990
|
<script src="demo/markdownlint-browser.min.js"></script>
|
|
954
991
|
```
|
|
955
992
|
|