markdownlint 0.37.3 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +2 -3
  3. package/README.md +39 -21
  4. package/doc/Rules.md +158 -35
  5. package/doc/md027.md +8 -0
  6. package/doc/md038.md +23 -11
  7. package/doc/md041.md +31 -16
  8. package/doc/md043.md +22 -4
  9. package/doc/md045.md +9 -1
  10. package/doc/md051.md +17 -0
  11. package/doc/md052.md +12 -0
  12. package/doc/md053.md +3 -3
  13. package/doc/md059.md +30 -0
  14. package/helpers/README.md +2 -2
  15. package/helpers/helpers.cjs +4 -6
  16. package/helpers/micromark-helpers.cjs +29 -3
  17. package/helpers/package.json +1 -1
  18. package/lib/cache.mjs +19 -5
  19. package/lib/configuration-strict.d.ts +190 -126
  20. package/lib/constants.mjs +1 -1
  21. package/lib/defer-require.cjs +16 -0
  22. package/lib/exports.d.mts +2 -0
  23. package/lib/exports.mjs +2 -0
  24. package/lib/markdownit.cjs +6 -13
  25. package/lib/markdownlint.d.mts +36 -2
  26. package/lib/markdownlint.mjs +314 -292
  27. package/lib/md025.mjs +23 -15
  28. package/lib/md027.mjs +11 -1
  29. package/lib/md036.mjs +12 -2
  30. package/lib/md038.mjs +52 -71
  31. package/lib/md039.mjs +3 -22
  32. package/lib/md041.mjs +54 -16
  33. package/lib/md043.mjs +2 -0
  34. package/lib/md045.mjs +3 -1
  35. package/lib/md051.mjs +13 -5
  36. package/lib/md052.mjs +2 -1
  37. package/lib/md059.mjs +71 -0
  38. package/lib/micromark-parse.mjs +14 -3
  39. package/lib/node-imports-browser.mjs +0 -2
  40. package/lib/node-imports-node.mjs +0 -3
  41. package/lib/parse-configuration.mjs +46 -0
  42. package/lib/resolve-module.cjs +52 -0
  43. package/lib/resolve-module.d.cts +34 -0
  44. package/lib/rules.mjs +3 -1
  45. package/package.json +30 -27
  46. package/schema/.markdownlint.jsonc +82 -60
  47. package/schema/.markdownlint.yaml +74 -56
  48. package/schema/markdownlint-config-schema-strict.json +259 -144
  49. package/schema/markdownlint-config-schema.json +259 -144
  50. package/lib/node-imports-browser-module.cjs +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.0
4
+
5
+ - Add MD059/descriptive-link-text
6
+ - Improve MD025/MD027/MD036/MD038/MD041/MD043/MD045/MD051/MD052
7
+ - `markdown-it` parser no longer a production dependency (breaking change)
8
+ - Add `markdownItFactory` option, remove `markdownItPlugins` option
9
+ - Remove support for end-of-life Node version 18
10
+ - Improve performance
11
+ - Update dependencies
12
+
13
+ ## 0.37.4
14
+
15
+ - Stop using `module.createRequire`, export `resolveModule`
16
+
3
17
  ## 0.37.3
4
18
 
5
19
  - Tweak `package.json` dependencies to work with `pnpm`
package/CONTRIBUTING.md CHANGED
@@ -14,8 +14,8 @@ Match the coding style of the files you edit. Although everyone has their own
14
14
  preferences and opinions, a pull request is not the right forum to debate them.
15
15
 
16
16
  Do not add new [`dependencies` to `package.json`][dependencies]. The Markdown
17
- parsers [`markdown-it`][markdown-it] and [`micromark`][micromark] are the
18
- project's only dependencies.
17
+ parser [`micromark`][micromark] (and its extensions) is this project's only
18
+ dependency.
19
19
 
20
20
  Package versions for `dependencies` and `devDependencies` should be specified
21
21
  exactly (also known as "pinning"). The short explanation is that doing otherwise
@@ -85,7 +85,6 @@ Thank you!
85
85
  [custom-rules]: doc/CustomRules.md
86
86
  [dependencies]: https://docs.npmjs.com/files/package.json#dependencies
87
87
  [example-com]: https://en.wikipedia.org/wiki/Example.com
88
- [markdown-it]: https://www.npmjs.com/package/markdown-it
89
88
  [micromark]: https://www.npmjs.com/package/micromark
90
89
  [new-rule]: https://github.com/DavidAnson/markdownlint/labels/new%20rule
91
90
  [npm-scripts]: https://docs.npmjs.com/misc/scripts
package/README.md CHANGED
@@ -24,7 +24,7 @@ for Markdown files. It was inspired by - and heavily influenced by - Mark
24
24
  Harrison's [markdownlint][markdownlint-ruby] for Ruby. The initial rules, rule
25
25
  documentation, and test cases came from that project.
26
26
 
27
- `markdownlint` uses the [`micromark`][micromark] parser and honors the
27
+ `markdownlint` uses the [`micromark` parser][micromark] and honors the
28
28
  [CommonMark][commonmark] specification for Markdown. It additionally supports
29
29
  popular [GitHub Flavored Markdown (GFM)][gfm] syntax like autolinks and tables
30
30
  as well as directives, footnotes, and math syntax - all implemented by
@@ -55,6 +55,7 @@ as well as directives, footnotes, and math syntax - all implemented by
55
55
  - [vscode-markdownlint extension for VS Code][vscode-markdownlint]
56
56
  - [Sublime Text markdownlint for Sublime Text][sublimelinter]
57
57
  - [coc-markdownlint extension for Vim/Neovim][coc]
58
+ - [flymake-markdownlint-cli2 extension for Emacs][emacs-flymake]
58
59
  - Tooling
59
60
  - [eslint-plugin-markdownlint for the ESLint analyzer][eslint-plugin]
60
61
  - [grunt-markdownlint for the Grunt task runner][grunt-markdownlint]
@@ -65,6 +66,7 @@ as well as directives, footnotes, and math syntax - all implemented by
65
66
 
66
67
  [cake]: https://github.com/cake-contrib/Cake.Markdownlint
67
68
  [coc]: https://github.com/fannheyward/coc-markdownlint
69
+ [emacs-flymake]: https://github.com/ewilderj/flymake-markdownlint-cli2
68
70
  [eslint-plugin]: https://github.com/paweldrozd/eslint-plugin-markdownlint
69
71
  [grunt-markdownlint]: https://github.com/sagiegurari/grunt-markdownlint
70
72
  [markdownlint-cli]: https://github.com/igorshubovych/markdownlint-cli
@@ -146,6 +148,7 @@ playground for learning and exploring.
146
148
  - **[MD055](doc/md055.md)** *table-pipe-style* - Table pipe style
147
149
  - **[MD056](doc/md056.md)** *table-column-count* - Table column count
148
150
  - **[MD058](doc/md058.md)** *blanks-around-tables* - Tables should be surrounded by blank lines
151
+ - **[MD059](doc/md059.md)** *descriptive-link-text* - Link text should be descriptive
149
152
 
150
153
  <!-- markdownlint-restore -->
151
154
 
@@ -165,7 +168,7 @@ To implement your own rules, refer to [CustomRules.md](doc/CustomRules.md).
165
168
  Tags group related rules and can be used to enable/disable multiple
166
169
  rules at once.
167
170
 
168
- - **`accessibility`** - `MD045`
171
+ - **`accessibility`** - `MD045`, `MD059`
169
172
  - **`atx`** - `MD018`, `MD019`
170
173
  - **`atx_closed`** - `MD020`, `MD021`
171
174
  - **`blank_lines`** - `MD012`, `MD022`, `MD031`, `MD032`, `MD047`
@@ -183,7 +186,7 @@ rules at once.
183
186
  - **`language`** - `MD040`
184
187
  - **`line_length`** - `MD013`
185
188
  - **`links`** - `MD011`, `MD034`, `MD039`, `MD042`, `MD051`, `MD052`, `MD053`,
186
- `MD054`
189
+ `MD054`, `MD059`
187
190
  - **`ol`** - `MD029`, `MD030`, `MD032`
188
191
  - **`spaces`** - `MD018`, `MD019`, `MD020`, `MD021`, `MD023`
189
192
  - **`spelling`** - `MD044`
@@ -418,9 +421,9 @@ object.
418
421
  See [ValidatingConfiguration.md](schema/ValidatingConfiguration.md) for ways to
419
422
  use the JSON Schema to validate configuration.
420
423
 
421
- For more advanced scenarios, styles can reference and extend other styles.
422
- The `readConfig` and `readConfigSync` functions can be used to read such
423
- styles.
424
+ For more advanced scenarios, styles can reference and build upon other styles
425
+ via the `extends` keyword and a file path or (installed) package name. The
426
+ `readConfig` function can be used to read such aggregate styles from code.
424
427
 
425
428
  For example, assuming a `base.json` configuration file:
426
429
 
@@ -567,28 +570,43 @@ This setting can be useful in the presence of (custom) rules that encounter
567
570
  unexpected syntax and fail. By enabling this option, the linting process
568
571
  is allowed to continue and report any violations that were found.
569
572
 
570
- ##### options.markdownItPlugins
573
+ ##### options.markdownItFactory
571
574
 
572
- Type: `Array` of `Array` of `Function` and plugin parameters
575
+ Type: `Function` returning an instance of a [`markdown-it` parser][markdown-it]
573
576
 
574
- Specifies additional [`markdown-it` plugins][markdown-it-plugin] to use when
575
- parsing input. Plugins can be used to support additional syntax and features for
576
- advanced scenarios. *Deprecated.*
577
+ Provides a factory function for creating instances of the `markdown-it` parser.
577
578
 
578
- [markdown-it-plugin]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
579
+ Previous versions of the `markdownlint` library declared `markdown-it` as a
580
+ direct dependency. This function makes it possible to avoid that dependency
581
+ entirely. In cases where `markdown-it` is needed, the caller is responsible for
582
+ declaring the dependency and returning an instance from this factory. If any
583
+ [`markdown-it` plugins][markdown-it-plugin] are needed, they should be `use`d by
584
+ the caller before returning the `markdown-it` instance.
585
+
586
+ For compatibility with previous versions of `markdownlint`, this function should
587
+ be similar to:
588
+
589
+ ```javascript
590
+ import markdownIt from "markdown-it";
591
+ const markdownItFactory = () => markdownIt({ "html": true });
592
+ ```
579
593
 
580
- Each item in the top-level `Array` should be of the form:
594
+ When an asynchronous implementation of `lint` is being invoked (e.g., via
595
+ `markdownlint/async` or `markdownlint/promise`), this function can return a
596
+ `Promise` in order to defer the import of `markdown-it`:
581
597
 
582
598
  ```javascript
583
- [ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
599
+ const markdownItFactory = () => import("markdown-it").then((module) => module.default({ "html": true }));
584
600
  ```
585
601
 
586
- > Note that `markdown-it` plugins are only called when the `markdown-it` parser
587
- > is invoked. None of the built-in rules use the `markdown-it` parser, so
588
- > `markdown-it` plugins will only be invoked when one or more
589
- > [custom rules][custom-rules] that use the `markdown-it` parser are present.
602
+ > Note that this function is only invoked when a `markdown-it` parser is
603
+ > needed. None of the built-in rules use the `markdown-it` parser, so it is only
604
+ > invoked when one or more [custom rules][custom-rules] are present that use the
605
+ > `markdown-it` parser.
590
606
 
591
607
  [custom-rules]: #custom-rules
608
+ [markdown-it]: https://github.com/markdown-it/markdown-it
609
+ [markdown-it-plugin]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
592
610
 
593
611
  ##### options.noInlineConfig
594
612
 
@@ -660,9 +678,9 @@ uses rule aliases (ex: `no-hard-tabs`) instead of names (ex: `MD010`).
660
678
  ### Config
661
679
 
662
680
  The `options.config` configuration object is simple and can be stored in a file
663
- for readability and easy reuse. The `readConfig` and `readConfigSync` functions
664
- load configuration settings and support the `extends` keyword for referencing
665
- other files (see above).
681
+ for readability and easy reuse. The `readConfig` function loads configuration
682
+ settings and supports the `extends` keyword for referencing files or packages
683
+ (see above).
666
684
 
667
685
  By default, configuration files are parsed as JSON (and named
668
686
  `.markdownlint.json`). Custom parsers can be provided to handle other formats
package/doc/Rules.md CHANGED
@@ -943,6 +943,10 @@ Tags: `blockquote`, `indentation`, `whitespace`
943
943
 
944
944
  Aliases: `no-multiple-space-blockquote`
945
945
 
946
+ Parameters:
947
+
948
+ - `list_items`: Include list items (`boolean`, default `true`)
949
+
946
950
  Fixable: Some violations can be fixed by tooling
947
951
 
948
952
  This rule is triggered when blockquotes have more than one space after the
@@ -960,6 +964,10 @@ To fix, remove any extraneous space:
960
964
  > indentation.
961
965
  ```
962
966
 
967
+ Inferring intended list indentation within a blockquote can be challenging;
968
+ setting the `list_items` parameter to `false` disables this rule for ordered
969
+ and unordered list items.
970
+
963
971
  Rationale: Consistent formatting makes it easier to understand a document.
964
972
 
965
973
  <a name="md028"></a>
@@ -1528,38 +1536,50 @@ Aliases: `no-space-in-code`
1528
1536
 
1529
1537
  Fixable: Some violations can be fixed by tooling
1530
1538
 
1531
- This rule is triggered for code span elements that have spaces adjacent to the
1532
- backticks:
1539
+ This rule is triggered for code spans containing content with unnecessary space
1540
+ next to the beginning or ending backticks:
1533
1541
 
1534
1542
  ```markdown
1535
1543
  `some text `
1536
1544
 
1537
1545
  ` some text`
1546
+
1547
+ ` some text `
1538
1548
  ```
1539
1549
 
1540
- To fix this, remove any spaces adjacent to the backticks:
1550
+ To fix this, remove the extra space characters from the beginning and ending:
1541
1551
 
1542
1552
  ```markdown
1543
1553
  `some text`
1544
1554
  ```
1545
1555
 
1546
- Note: A single leading and trailing space is allowed by the specification and
1547
- automatically trimmed (in order to allow for code spans that embed backticks):
1556
+ Note: A single leading *and* trailing space is allowed by the specification and
1557
+ trimmed by the parser to support code spans that begin or end with a backtick:
1548
1558
 
1549
1559
  ```markdown
1550
1560
  `` `backticks` ``
1561
+
1562
+ `` backtick` ``
1563
+ ```
1564
+
1565
+ Note: When single-space padding is present in the input, it will be preserved
1566
+ (even if unnecessary):
1567
+
1568
+ ```markdown
1569
+ ` code `
1551
1570
  ```
1552
1571
 
1553
- Note: A single leading or trailing space is allowed if used to separate code
1554
- span markers from an embedded backtick (though the space is not trimmed):
1572
+ Note: Code spans containing only spaces are allowed by the specification and are
1573
+ also preserved:
1555
1574
 
1556
1575
  ```markdown
1557
- `` ` embedded backtick``
1576
+ ` `
1577
+
1578
+ ` `
1558
1579
  ```
1559
1580
 
1560
- Rationale: Violations of this rule are usually unintentional and may lead to
1561
- improperly-rendered content. If spaces beside backticks are intentional, this
1562
- rule can be disabled for that line or file.
1581
+ Rationale: Violations of this rule are usually unintentional and can lead to
1582
+ improperly-rendered content.
1563
1583
 
1564
1584
  <a name="md039"></a>
1565
1585
 
@@ -1650,48 +1670,63 @@ Aliases: `first-line-h1`, `first-line-heading`
1650
1670
 
1651
1671
  Parameters:
1652
1672
 
1673
+ - `allow_preamble`: Allow content before first heading (`boolean`, default
1674
+ `false`)
1653
1675
  - `front_matter_title`: RegExp for matching title in front matter (`string`,
1654
1676
  default `^\s*title\s*[:=]`)
1655
1677
  - `level`: Heading level (`integer`, default `1`)
1656
1678
 
1657
1679
  This rule is intended to ensure documents have a title and is triggered when
1658
- the first line in the file isn't a top-level (h1) heading:
1680
+ the first line in a document is not a top-level ([HTML][HTML] `h1`) heading:
1659
1681
 
1660
1682
  ```markdown
1661
- This is a file without a heading
1683
+ This is a document without a heading
1662
1684
  ```
1663
1685
 
1664
- To fix this, add a top-level heading to the beginning of the file:
1686
+ To fix this, add a top-level heading to the beginning of the document:
1665
1687
 
1666
1688
  ```markdown
1667
- # File with heading
1689
+ # Document Heading
1668
1690
 
1669
- This is a file with a top-level heading
1691
+ This is a document with a top-level heading
1670
1692
  ```
1671
1693
 
1672
1694
  Because it is common for projects on GitHub to use an image for the heading of
1673
- `README.md` and that is not well-supported by Markdown, HTML headings are also
1674
- permitted by this rule. For example:
1695
+ `README.md` and that pattern is not well-supported by Markdown, HTML headings
1696
+ are also permitted by this rule. For example:
1675
1697
 
1676
1698
  ```markdown
1677
1699
  <h1 align="center"><img src="https://placekitten.com/300/150"/></h1>
1678
1700
 
1679
- This is a file with a top-level HTML heading
1701
+ This is a document with a top-level HTML heading
1680
1702
  ```
1681
1703
 
1682
- Note: The `level` parameter can be used to change the top-level (ex: to h2) in
1683
- cases where an h1 is added externally.
1704
+ In some cases, a document's title heading may be preceded by text like a table
1705
+ of contents. This is not ideal for accessibility, but can be allowed by setting
1706
+ the `allow_preamble` parameter to `true`.
1684
1707
 
1685
- If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
1686
- contains a `title` property (commonly used with blog posts), this rule will not
1687
- report a violation. To use a different property name in the front matter,
1688
- specify the text of a regular expression via the `front_matter_title` parameter.
1689
- To disable the use of front matter by this rule, specify `""` for
1690
- `front_matter_title`.
1708
+ ```markdown
1709
+ This is a document with preamble text
1710
+
1711
+ # Document Heading
1712
+ ```
1713
+
1714
+ If [YAML][YAML] front matter is present and contains a `title` property
1715
+ (commonly used with blog posts), this rule will not report a violation. To use a
1716
+ different property name in the front matter, specify the text of a [regular
1717
+ expression][RegExp] via the `front_matter_title` parameter. To disable the use
1718
+ of front matter by this rule, specify `""` for `front_matter_title`.
1719
+
1720
+ The `level` parameter can be used to change the top-level heading (ex: to `h2`)
1721
+ in cases where an `h1` is added externally.
1691
1722
 
1692
1723
  Rationale: The top-level heading often acts as the title of a document. More
1693
1724
  information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
1694
1725
 
1726
+ [HTML]: https://en.wikipedia.org/wiki/HTML
1727
+ [RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
1728
+ [YAML]: https://en.wikipedia.org/wiki/YAML
1729
+
1695
1730
  <a name="md042"></a>
1696
1731
 
1697
1732
  ## `MD042` - No empty links
@@ -1747,7 +1782,7 @@ structure for a set of files.
1747
1782
  To require exactly the following structure:
1748
1783
 
1749
1784
  ```markdown
1750
- # Head
1785
+ # Heading
1751
1786
  ## Item
1752
1787
  ### Detail
1753
1788
  ```
@@ -1756,7 +1791,7 @@ Set the `headings` parameter to:
1756
1791
 
1757
1792
  ```json
1758
1793
  [
1759
- "# Head",
1794
+ "# Heading",
1760
1795
  "## Item",
1761
1796
  "### Detail"
1762
1797
  ]
@@ -1765,7 +1800,7 @@ Set the `headings` parameter to:
1765
1800
  To allow optional headings as with the following structure:
1766
1801
 
1767
1802
  ```markdown
1768
- # Head
1803
+ # Heading
1769
1804
  ## Item
1770
1805
  ### Detail (optional)
1771
1806
  ## Foot
@@ -1778,7 +1813,7 @@ special value `"+"` meaning "one or more unspecified headings" and set the
1778
1813
 
1779
1814
  ```json
1780
1815
  [
1781
- "# Head",
1816
+ "# Heading",
1782
1817
  "## Item",
1783
1818
  "*",
1784
1819
  "## Foot",
@@ -1786,6 +1821,24 @@ special value `"+"` meaning "one or more unspecified headings" and set the
1786
1821
  ]
1787
1822
  ```
1788
1823
 
1824
+ To allow a single required heading to vary as with a project name:
1825
+
1826
+ ```markdown
1827
+ # Project Name
1828
+ ## Description
1829
+ ## Examples
1830
+ ```
1831
+
1832
+ Use the special value `"?"` meaning "exactly one unspecified heading":
1833
+
1834
+ ```json
1835
+ [
1836
+ "?",
1837
+ "## Description",
1838
+ "## Examples"
1839
+ ]
1840
+ ```
1841
+
1789
1842
  When an error is detected, this rule outputs the line number of the first
1790
1843
  problematic heading (otherwise, it outputs the last line number of the file).
1791
1844
 
@@ -1855,7 +1908,7 @@ Tags: `accessibility`, `images`
1855
1908
 
1856
1909
  Aliases: `no-alt-text`
1857
1910
 
1858
- This rule is triggered when an image is missing alternate text (alt text)
1911
+ This rule reports a violation when an image is missing alternate text (alt text)
1859
1912
  information.
1860
1913
 
1861
1914
  Alternate text is commonly specified inline as:
@@ -1880,12 +1933,20 @@ Or with HTML as:
1880
1933
  <img src="image.jpg" alt="Alternate text" />
1881
1934
  ```
1882
1935
 
1936
+ Note: If the [HTML `aria-hidden` attribute][aria-hidden] is used to hide the
1937
+ image from assistive technology, this rule does not report a violation:
1938
+
1939
+ ```html
1940
+ <img src="image.jpg" aria-hidden="true" />
1941
+ ```
1942
+
1883
1943
  Guidance for writing alternate text is available from the [W3C][w3c],
1884
1944
  [Wikipedia][wikipedia], and [other locations][phase2technology].
1885
1945
 
1886
1946
  Rationale: Alternate text is important for accessibility and describes the
1887
1947
  content of an image for people who may not be able to see it.
1888
1948
 
1949
+ [aria-hidden]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-hidden
1889
1950
  [phase2technology]: https://www.phase2technology.com/blog/no-more-excuses
1890
1951
  [w3c]: https://www.w3.org/WAI/alt/
1891
1952
  [wikipedia]: https://en.wikipedia.org/wiki/Alt_attribute
@@ -2103,6 +2164,8 @@ Aliases: `link-fragments`
2103
2164
  Parameters:
2104
2165
 
2105
2166
  - `ignore_case`: Ignore case of fragments (`boolean`, default `false`)
2167
+ - `ignored_pattern`: Pattern for ignoring additional fragments (`string`,
2168
+ default ``)
2106
2169
 
2107
2170
  Fixable: Some violations can be fixed by tooling
2108
2171
 
@@ -2160,6 +2223,13 @@ attribute can be used to define a fragment:
2160
2223
  An `a` tag can be useful in scenarios where a heading is not appropriate or for
2161
2224
  control over the text of the fragment identifier.
2162
2225
 
2226
+ [HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
2227
+ rule allows that syntax (using lower-case for consistency):
2228
+
2229
+ ```markdown
2230
+ [Link](#top)
2231
+ ```
2232
+
2163
2233
  This rule also recognizes the custom fragment syntax used by GitHub to highlight
2164
2234
  [specific content in a document][github-linking-to-content].
2165
2235
 
@@ -2175,6 +2245,12 @@ And this link to content starting within line 19 running into line 21:
2175
2245
  [Link](#L19C5-L21C11)
2176
2246
  ```
2177
2247
 
2248
+ Some Markdown generators dynamically create and insert headings when building
2249
+ documents, for example by combining a fixed prefix like `figure-` and an
2250
+ incrementing numeric counter. To ignore such generated fragments, set the
2251
+ `ignored_pattern` [regular expression][RegEx] parameter to a pattern that
2252
+ matches (e.g., `^figure-`).
2253
+
2178
2254
  Rationale: [GitHub section links][github-section-links] are created
2179
2255
  automatically for every heading when Markdown content is displayed on GitHub.
2180
2256
  This makes it easy to link directly to different sections within a document.
@@ -2189,6 +2265,8 @@ append an incrementing integer as needed for uniqueness.
2189
2265
  [github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
2190
2266
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
2191
2267
  [github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
2268
+ [html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
2269
+ [RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
2192
2270
 
2193
2271
  <a name="md052"></a>
2194
2272
 
@@ -2200,6 +2278,7 @@ Aliases: `reference-links-images`
2200
2278
 
2201
2279
  Parameters:
2202
2280
 
2281
+ - `ignored_labels`: Ignored link labels (`string[]`, default `["x"]`)
2203
2282
  - `shortcut_syntax`: Include shortcut syntax (`boolean`, default `false`)
2204
2283
 
2205
2284
  Links and images in Markdown can provide the link destination or image source
@@ -2233,6 +2312,17 @@ the `include_shortcut` parameter to `true`. Note that doing so produces warnings
2233
2312
  for *all* text in the document that *could* be a shortcut. If bracketed text is
2234
2313
  intentional, brackets can be escaped with the `\` character: `\[example\]`.
2235
2314
 
2315
+ If there are link labels that are deliberately unreferenced, they can be ignored
2316
+ by setting the `ignored_labels` parameter to the list of strings to ignore. The
2317
+ default value of this parameter ignores the checkbox syntax used by
2318
+ [GitHub Flavored Markdown task list items][gfm-tasklist]:
2319
+
2320
+ ```markdown
2321
+ - [x] Checked task list item
2322
+ ```
2323
+
2324
+ [gfm-tasklist]: https://github.github.com/gfm/#task-list-items-extension-
2325
+
2236
2326
  <a name="md053"></a>
2237
2327
 
2238
2328
  ## `MD053` - Link and image reference definitions should be needed
@@ -2266,9 +2356,9 @@ reference has the corresponding label. The "full", "collapsed", and "shortcut"
2266
2356
  formats are all supported.
2267
2357
 
2268
2358
  If there are reference definitions that are deliberately unreferenced, they can
2269
- be ignored by setting the `ignored_definitions` parameter. The default value of
2270
- this parameter ignores the following convention for adding non-HTML comments to
2271
- Markdown:
2359
+ be ignored by setting the `ignored_definitions` parameter to the list of strings
2360
+ to ignore. The default value of this parameter ignores the following convention
2361
+ for adding non-HTML comments to Markdown:
2272
2362
 
2273
2363
  ```markdown
2274
2364
  [//]: # (This behaves like a comment)
@@ -2526,6 +2616,39 @@ Some text
2526
2616
  Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
2527
2617
  tables that don't have blank lines before and after them.
2528
2618
 
2619
+ <a name="md059"></a>
2620
+
2621
+ ## `MD059` - Link text should be descriptive
2622
+
2623
+ Tags: `accessibility`, `links`
2624
+
2625
+ Aliases: `descriptive-link-text`
2626
+
2627
+ Parameters:
2628
+
2629
+ - `prohibited_texts`: Prohibited link texts (`string[]`, default `["click
2630
+ here","here","link","more"]`)
2631
+
2632
+ This rule is triggered when a link has generic text like `[click here](...)` or
2633
+ `[link](...)`.
2634
+
2635
+ Link text should be descriptive and communicate the purpose of the link (e.g.,
2636
+ `[Download the budget document](...)` or `[CommonMark Specification](...)`).
2637
+ This is especially important for screen readers which sometimes present links
2638
+ without context.
2639
+
2640
+ By default, this rule prohibits a small number of common English words/phrases.
2641
+ To customize that list of words/phrases, set the `prohibited_texts` parameter to
2642
+ an `Array` of `string`s.
2643
+
2644
+ Note: For languages other than English, use the `prohibited_texts` parameter to
2645
+ customize the list for that language. It is *not* a goal for this rule to have
2646
+ translations for every language.
2647
+
2648
+ Note: This rule checks Markdown links; HTML links are ignored.
2649
+
2650
+ More information: <https://webaim.org/techniques/hypertext/>
2651
+
2529
2652
  <!-- markdownlint-configure-file {
2530
2653
  "no-inline-html": {
2531
2654
  "allowed_elements": [
package/doc/md027.md CHANGED
@@ -4,6 +4,10 @@ Tags: `blockquote`, `indentation`, `whitespace`
4
4
 
5
5
  Aliases: `no-multiple-space-blockquote`
6
6
 
7
+ Parameters:
8
+
9
+ - `list_items`: Include list items (`boolean`, default `true`)
10
+
7
11
  Fixable: Some violations can be fixed by tooling
8
12
 
9
13
  This rule is triggered when blockquotes have more than one space after the
@@ -21,4 +25,8 @@ To fix, remove any extraneous space:
21
25
  > indentation.
22
26
  ```
23
27
 
28
+ Inferring intended list indentation within a blockquote can be challenging;
29
+ setting the `list_items` parameter to `false` disables this rule for ordered
30
+ and unordered list items.
31
+
24
32
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md038.md CHANGED
@@ -6,35 +6,47 @@ Aliases: `no-space-in-code`
6
6
 
7
7
  Fixable: Some violations can be fixed by tooling
8
8
 
9
- This rule is triggered for code span elements that have spaces adjacent to the
10
- backticks:
9
+ This rule is triggered for code spans containing content with unnecessary space
10
+ next to the beginning or ending backticks:
11
11
 
12
12
  ```markdown
13
13
  `some text `
14
14
 
15
15
  ` some text`
16
+
17
+ ` some text `
16
18
  ```
17
19
 
18
- To fix this, remove any spaces adjacent to the backticks:
20
+ To fix this, remove the extra space characters from the beginning and ending:
19
21
 
20
22
  ```markdown
21
23
  `some text`
22
24
  ```
23
25
 
24
- Note: A single leading and trailing space is allowed by the specification and
25
- automatically trimmed (in order to allow for code spans that embed backticks):
26
+ Note: A single leading *and* trailing space is allowed by the specification and
27
+ trimmed by the parser to support code spans that begin or end with a backtick:
26
28
 
27
29
  ```markdown
28
30
  `` `backticks` ``
31
+
32
+ `` backtick` ``
29
33
  ```
30
34
 
31
- Note: A single leading or trailing space is allowed if used to separate code
32
- span markers from an embedded backtick (though the space is not trimmed):
35
+ Note: When single-space padding is present in the input, it will be preserved
36
+ (even if unnecessary):
33
37
 
34
38
  ```markdown
35
- `` ` embedded backtick``
39
+ ` code `
40
+ ```
41
+
42
+ Note: Code spans containing only spaces are allowed by the specification and are
43
+ also preserved:
44
+
45
+ ```markdown
46
+ ` `
47
+
48
+ ` `
36
49
  ```
37
50
 
38
- Rationale: Violations of this rule are usually unintentional and may lead to
39
- improperly-rendered content. If spaces beside backticks are intentional, this
40
- rule can be disabled for that line or file.
51
+ Rationale: Violations of this rule are usually unintentional and can lead to
52
+ improperly-rendered content.