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.
Files changed (73) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +72 -35
  3. package/demo/markdownlint-browser.js +1259 -1215
  4. package/doc/CustomRules.md +55 -249
  5. package/doc/Rules.md +36 -29
  6. package/doc/md003.md +2 -2
  7. package/doc/md004.md +4 -3
  8. package/doc/md035.md +3 -8
  9. package/doc/md046.md +2 -2
  10. package/doc/md048.md +3 -2
  11. package/doc/md049.md +4 -3
  12. package/doc/md050.md +4 -4
  13. package/doc/md051.md +11 -3
  14. package/doc/md055.md +3 -2
  15. package/helpers/README.md +2 -19
  16. package/helpers/helpers.js +87 -347
  17. package/helpers/micromark-helpers.cjs +296 -0
  18. package/helpers/micromark-parse.cjs +313 -0
  19. package/helpers/package.json +5 -2
  20. package/helpers/shared.js +6 -0
  21. package/helpers/test.cjs +28 -0
  22. package/lib/cache.js +3 -3
  23. package/lib/configuration-strict.d.ts +120 -106
  24. package/lib/constants.js +1 -1
  25. package/lib/markdownit.cjs +172 -0
  26. package/lib/markdownlint.d.ts +41 -3
  27. package/lib/markdownlint.js +153 -115
  28. package/lib/md001.js +1 -1
  29. package/lib/md003.js +1 -1
  30. package/lib/md004.js +3 -3
  31. package/lib/md007.js +3 -3
  32. package/lib/md009.js +1 -1
  33. package/lib/md010.js +18 -14
  34. package/lib/md011.js +24 -23
  35. package/lib/md012.js +1 -1
  36. package/lib/md013.js +1 -1
  37. package/lib/md014.js +5 -9
  38. package/lib/md018.js +1 -1
  39. package/lib/md019-md021.js +1 -1
  40. package/lib/md020.js +2 -2
  41. package/lib/md022.js +9 -15
  42. package/lib/md024.js +1 -1
  43. package/lib/md025.js +1 -1
  44. package/lib/md027.js +2 -2
  45. package/lib/md029.js +3 -3
  46. package/lib/md031.js +8 -6
  47. package/lib/md032.js +27 -15
  48. package/lib/md033.js +1 -1
  49. package/lib/md034.js +21 -29
  50. package/lib/md036.js +18 -24
  51. package/lib/md037.js +1 -1
  52. package/lib/md038.js +9 -14
  53. package/lib/md039.js +13 -15
  54. package/lib/md040.js +11 -13
  55. package/lib/md041.js +4 -4
  56. package/lib/md042.js +2 -6
  57. package/lib/md043.js +1 -1
  58. package/lib/md044.js +31 -28
  59. package/lib/md045.js +2 -2
  60. package/lib/md048.js +28 -17
  61. package/lib/md049-md050.js +20 -5
  62. package/lib/md051.js +16 -18
  63. package/lib/md053.js +5 -4
  64. package/lib/md054.js +11 -13
  65. package/lib/md055.js +39 -46
  66. package/lib/md056.js +31 -36
  67. package/lib/md058.js +29 -14
  68. package/package.json +14 -13
  69. package/schema/.markdownlint.jsonc +55 -52
  70. package/schema/.markdownlint.yaml +54 -52
  71. package/schema/markdownlint-config-schema-strict.json +132 -110
  72. package/schema/markdownlint-config-schema.json +132 -110
  73. 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](https://en.wikipedia.org/wiki/Markdown) markup language
17
- is designed to be easy to read, write, and understand. It succeeds -
18
- and its flexibility is both a benefit and a drawback. Many styles are
19
- possible, so formatting can be inconsistent. Some constructs don't
20
- work well in all parsers and should be avoided. The
21
- [CommonMark](https://commonmark.org/) specification standardizes
22
- 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.
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
- /((^---\s*$[\s\S]+?^---\s*)|(^\+\+\+\s*$[\s\S]+?^(\+\+\+|\.\.\.)\s*)|(^\{\s*$[\s\S]+?^\}\s*))(\r\n|\r|\n|$)/m
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. *This is
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. *This is
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. *This is
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). *This is the default.*
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 `markdown-it` and `markdownlint`:
985
+ Then reference `markdownlint` and `micromark` scripts:
950
986
 
951
987
  ```html
952
- <script src="demo/markdown-it.min.js"></script>
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