markdownlint 0.21.0 → 0.23.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/CONTRIBUTING.md +1 -0
- package/LICENSE +1 -1
- package/README.md +106 -70
- package/demo/markdownlint-browser.js +1037 -1600
- package/doc/Rules.md +106 -76
- package/helpers/LICENSE +1 -1
- package/helpers/helpers.js +83 -33
- package/helpers/package.json +1 -1
- package/lib/markdownlint.d.ts +11 -5
- package/lib/markdownlint.js +102 -38
- package/lib/md002.js +1 -1
- package/lib/md004.js +46 -13
- package/lib/md006.js +1 -1
- package/lib/md009.js +25 -23
- package/lib/md011.js +10 -6
- package/lib/md018.js +1 -1
- package/lib/md019.js +1 -1
- package/lib/md020.js +1 -1
- package/lib/md021.js +1 -1
- package/lib/md023.js +1 -1
- package/lib/md025.js +1 -1
- package/lib/md026.js +7 -4
- package/lib/md028.js +1 -9
- package/lib/md031.js +6 -5
- package/lib/md032.js +2 -2
- package/lib/md037.js +22 -8
- package/lib/md039.js +2 -2
- package/lib/md041.js +14 -3
- package/lib/md043.js +22 -11
- package/lib/rules.js +2 -1
- package/package.json +32 -33
- package/schema/.markdownlint.jsonc +250 -0
- package/schema/.markdownlint.yaml +225 -0
- package/schema/markdownlint-config-schema.json +23 -20
- package/schema/build-config-schema.js +0 -410
package/doc/Rules.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Rules
|
|
2
2
|
|
|
3
3
|
This document contains a description of all rules, what they are checking for,
|
|
4
|
-
as well as
|
|
4
|
+
as well as examples of documents that break the rule and corrected
|
|
5
5
|
versions of the examples. Any rule whose heading is ~~struck through~~ is
|
|
6
6
|
deprecated, but still provided for backward-compatibility.
|
|
7
7
|
|
|
@@ -47,7 +47,7 @@ when skipped - especially for accessibility scenarios. More information:
|
|
|
47
47
|
|
|
48
48
|
<a name="md002"></a>
|
|
49
49
|
|
|
50
|
-
## ~~MD002 - First heading should be a top
|
|
50
|
+
## ~~MD002 - First heading should be a top-level heading~~
|
|
51
51
|
|
|
52
52
|
Tags: headings, headers
|
|
53
53
|
|
|
@@ -59,26 +59,26 @@ Parameters: level (number; default 1)
|
|
|
59
59
|
> [MD041/first-line-heading](#md041) offers an improved implementation.
|
|
60
60
|
|
|
61
61
|
This rule is intended to ensure document headings start at the top level and
|
|
62
|
-
is triggered when the first heading in the document isn't
|
|
62
|
+
is triggered when the first heading in the document isn't an h1 heading:
|
|
63
63
|
|
|
64
64
|
```markdown
|
|
65
|
-
## This isn't
|
|
65
|
+
## This isn't an H1 heading
|
|
66
66
|
|
|
67
67
|
### Another heading
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
The first heading in the document should be
|
|
70
|
+
The first heading in the document should be an h1 heading:
|
|
71
71
|
|
|
72
72
|
```markdown
|
|
73
|
-
# Start with
|
|
73
|
+
# Start with an H1 heading
|
|
74
74
|
|
|
75
75
|
## Then use an H2 for subsections
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Note: The `level` parameter can be used to change the top
|
|
79
|
-
cases where
|
|
78
|
+
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
|
79
|
+
cases where an h1 is added externally.
|
|
80
80
|
|
|
81
|
-
Rationale: The top
|
|
81
|
+
Rationale: The top-level heading often acts as the title of a document. More
|
|
82
82
|
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
|
83
83
|
|
|
84
84
|
<a name="md003"></a>
|
|
@@ -127,7 +127,7 @@ Setext style H2
|
|
|
127
127
|
|
|
128
128
|
Note: the configured heading style can be a specific style to use (atx,
|
|
129
129
|
atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require
|
|
130
|
-
that the usage
|
|
130
|
+
that the usage is consistent within the document.
|
|
131
131
|
|
|
132
132
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
133
133
|
|
|
@@ -142,6 +142,8 @@ Aliases: ul-style
|
|
|
142
142
|
Parameters: style ("consistent", "asterisk", "plus", "dash", "sublist"; default
|
|
143
143
|
"consistent")
|
|
144
144
|
|
|
145
|
+
Fixable: Most violations can be fixed by tooling
|
|
146
|
+
|
|
145
147
|
This rule is triggered when the symbols used in the document for unordered
|
|
146
148
|
list items do not match the configured unordered list style:
|
|
147
149
|
|
|
@@ -161,11 +163,12 @@ document:
|
|
|
161
163
|
```
|
|
162
164
|
|
|
163
165
|
The configured list style can be a specific symbol to use (asterisk, plus, dash),
|
|
164
|
-
|
|
165
|
-
sublist
|
|
166
|
+
to ensure that all list styling is consistent, or to ensure that each
|
|
167
|
+
sublist has a consistent symbol that differs from its parent list.
|
|
166
168
|
|
|
167
169
|
For example, the following is valid for the `sublist` style because the outer-most
|
|
168
|
-
indent uses asterisk, the middle indent uses plus, and the inner-most indent uses
|
|
170
|
+
indent uses asterisk, the middle indent uses plus, and the inner-most indent uses
|
|
171
|
+
dash:
|
|
169
172
|
|
|
170
173
|
```markdown
|
|
171
174
|
* Item 1
|
|
@@ -198,7 +201,7 @@ but don't have the same indentation:
|
|
|
198
201
|
* A misaligned item
|
|
199
202
|
```
|
|
200
203
|
|
|
201
|
-
Usually this rule will be triggered because of a typo. Correct the indentation
|
|
204
|
+
Usually, this rule will be triggered because of a typo. Correct the indentation
|
|
202
205
|
for the list to fix it:
|
|
203
206
|
|
|
204
207
|
```markdown
|
|
@@ -244,7 +247,7 @@ Aliases: ul-start-left
|
|
|
244
247
|
|
|
245
248
|
Fixable: Most violations can be fixed by tooling
|
|
246
249
|
|
|
247
|
-
This rule is triggered when top
|
|
250
|
+
This rule is triggered when top-level lists don't start at the beginning of a
|
|
248
251
|
line:
|
|
249
252
|
|
|
250
253
|
```markdown
|
|
@@ -254,7 +257,7 @@ Some text
|
|
|
254
257
|
* List item
|
|
255
258
|
```
|
|
256
259
|
|
|
257
|
-
To fix, ensure that top
|
|
260
|
+
To fix, ensure that top-level list items are not indented:
|
|
258
261
|
|
|
259
262
|
```markdown
|
|
260
263
|
Some test
|
|
@@ -322,7 +325,7 @@ Rationale: Indenting by 2 spaces allows the content of a nested list to be in
|
|
|
322
325
|
line with the start of the content of the parent list when a single space is
|
|
323
326
|
used after the list marker. Indenting by 4 spaces is consistent with code blocks
|
|
324
327
|
and simpler for editors to implement. Additionally, this can be a compatibility
|
|
325
|
-
issue for multi-markdown parsers, which require
|
|
328
|
+
issue for multi-markdown parsers, which require 4-space indents. More information:
|
|
326
329
|
<https://cirosantilli.com/markdown-style-guide#indentation-of-content-inside-lists>
|
|
327
330
|
and <http://support.markedapp.com/discussions/problems/21-sub-lists-not-indenting>.
|
|
328
331
|
|
|
@@ -334,13 +337,20 @@ Tags: whitespace
|
|
|
334
337
|
|
|
335
338
|
Aliases: no-trailing-spaces
|
|
336
339
|
|
|
340
|
+
<!-- markdownlint-disable line-length -->
|
|
341
|
+
|
|
337
342
|
Parameters: br_spaces, list_item_empty_lines, strict (number; default 2, boolean; default false, boolean; default false)
|
|
338
343
|
|
|
344
|
+
<!-- markdownlint-restore -->
|
|
345
|
+
|
|
339
346
|
Fixable: Most violations can be fixed by tooling
|
|
340
347
|
|
|
341
348
|
This rule is triggered on any lines that end with unexpected whitespace. To fix this,
|
|
342
349
|
remove the trailing space from the end of the line.
|
|
343
350
|
|
|
351
|
+
Note: Trailing space is allowed in indented and fenced code blocks because some
|
|
352
|
+
languages require it.
|
|
353
|
+
|
|
344
354
|
The `br_spaces` parameter allows an exception to this rule for a specific number
|
|
345
355
|
of trailing spaces, typically used to insert an explicit line break. The default
|
|
346
356
|
value allows 2 spaces to indicate a hard break (\<br> element).
|
|
@@ -396,7 +406,7 @@ Some text
|
|
|
396
406
|
* hard tab character used to indent the list item
|
|
397
407
|
```
|
|
398
408
|
|
|
399
|
-
<!-- markdownlint-
|
|
409
|
+
<!-- markdownlint-restore -->
|
|
400
410
|
|
|
401
411
|
Corrected example:
|
|
402
412
|
|
|
@@ -437,7 +447,8 @@ To fix this, swap the `[]` and `()` around:
|
|
|
437
447
|
[Correct link syntax](https://www.example.com/)
|
|
438
448
|
```
|
|
439
449
|
|
|
440
|
-
Note: [Markdown Extra](https://en.wikipedia.org/wiki/Markdown_Extra)-style
|
|
450
|
+
Note: [Markdown Extra](https://en.wikipedia.org/wiki/Markdown_Extra)-style
|
|
451
|
+
footnotes do not trigger this rule:
|
|
441
452
|
|
|
442
453
|
```markdown
|
|
443
454
|
For (example)[^1]
|
|
@@ -496,7 +507,7 @@ Aliases: line-length
|
|
|
496
507
|
|
|
497
508
|
Parameters: line_length, heading_line_length, code_block_line_length, code_blocks, tables, headings, headers, strict, stern (number; default 80 for *_length, boolean; default true (except strict/stern which default false))
|
|
498
509
|
|
|
499
|
-
<!-- markdownlint-
|
|
510
|
+
<!-- markdownlint-restore -->
|
|
500
511
|
|
|
501
512
|
> If `headings` is not provided, `headers` (deprecated) will be used.
|
|
502
513
|
|
|
@@ -523,7 +534,7 @@ This-line-is-also-okay-because-there-are-no-spaces
|
|
|
523
534
|
```
|
|
524
535
|
|
|
525
536
|
In `strict` or `stern` modes, the two middle lines above are a violation. The
|
|
526
|
-
third line is a violation in `strict` mode
|
|
537
|
+
third line is a violation in `strict` mode but allowed in `stern` mode.
|
|
527
538
|
|
|
528
539
|
You have the option to exclude this rule for code blocks, tables, or headings.
|
|
529
540
|
To do so, set the `code_blocks`, `tables`, or `headings` parameter(s) to false.
|
|
@@ -556,7 +567,7 @@ $ cat foo
|
|
|
556
567
|
$ less bar
|
|
557
568
|
```
|
|
558
569
|
|
|
559
|
-
<!-- markdownlint-
|
|
570
|
+
<!-- markdownlint-restore -->
|
|
560
571
|
|
|
561
572
|
The dollar signs are unnecessary in this situation, and should not be
|
|
562
573
|
included:
|
|
@@ -761,7 +772,7 @@ number of blank lines (including 0) above or below each heading.
|
|
|
761
772
|
Note: If `lines_above` or `lines_below` are configured to require more than one
|
|
762
773
|
blank line, [MD012/no-multiple-blanks](#md012) should also be customized.
|
|
763
774
|
|
|
764
|
-
Rationale: Aside from aesthetic reasons, some parsers, including kramdown
|
|
775
|
+
Rationale: Aside from aesthetic reasons, some parsers, including `kramdown`, will
|
|
765
776
|
not parse headings that don't have a blank line before, and will parse them as
|
|
766
777
|
regular text.
|
|
767
778
|
|
|
@@ -823,7 +834,7 @@ To fix this, ensure that the content of each heading is different:
|
|
|
823
834
|
|
|
824
835
|
If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
|
|
825
836
|
set to `true`, heading duplication is allowed for non-sibling headings (common
|
|
826
|
-
in
|
|
837
|
+
in changelogs):
|
|
827
838
|
|
|
828
839
|
```markdown
|
|
829
840
|
# Change log
|
|
@@ -842,27 +853,27 @@ heading name; headings with the same content can cause problems with that.
|
|
|
842
853
|
|
|
843
854
|
<a name="md025"></a>
|
|
844
855
|
|
|
845
|
-
## MD025 - Multiple top
|
|
856
|
+
## MD025 - Multiple top-level headings in the same document
|
|
846
857
|
|
|
847
858
|
Tags: headings, headers
|
|
848
859
|
|
|
849
860
|
Aliases: single-title, single-h1
|
|
850
861
|
|
|
851
|
-
Parameters: level, front_matter_title (number; default 1, string; default "^\s*title
|
|
862
|
+
Parameters: level, front_matter_title (number; default 1, string; default "^\s*"?title"?\s*[:=]")
|
|
852
863
|
|
|
853
|
-
This rule is triggered when a top
|
|
854
|
-
the file is
|
|
864
|
+
This rule is triggered when a top-level heading is in use (the first line of
|
|
865
|
+
the file is an h1 heading), and more than one h1 heading is in use in the
|
|
855
866
|
document:
|
|
856
867
|
|
|
857
868
|
```markdown
|
|
858
869
|
# Top level heading
|
|
859
870
|
|
|
860
|
-
# Another top
|
|
871
|
+
# Another top-level heading
|
|
861
872
|
```
|
|
862
873
|
|
|
863
|
-
To fix, structure your document so
|
|
864
|
-
the title for the document
|
|
865
|
-
headings:
|
|
874
|
+
To fix, structure your document so there is a single h1 heading that is
|
|
875
|
+
the title for the document. Subsequent headings must be
|
|
876
|
+
lower-level headings (h2, h3, etc.):
|
|
866
877
|
|
|
867
878
|
```markdown
|
|
868
879
|
# Title
|
|
@@ -872,17 +883,17 @@ headings:
|
|
|
872
883
|
## Another heading
|
|
873
884
|
```
|
|
874
885
|
|
|
875
|
-
Note: The `level` parameter can be used to change the top
|
|
876
|
-
cases where
|
|
886
|
+
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
|
887
|
+
cases where an h1 is added externally.
|
|
877
888
|
|
|
878
889
|
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and contains
|
|
879
890
|
a `title` property (commonly used with blog posts), this rule treats that as a top
|
|
880
|
-
level heading and will report a violation for any subsequent top
|
|
881
|
-
To use a different property name in front matter, specify the text of a regular
|
|
891
|
+
level heading and will report a violation for any subsequent top-level headings.
|
|
892
|
+
To use a different property name in the front matter, specify the text of a regular
|
|
882
893
|
expression via the `front_matter_title` parameter. To disable the use of front
|
|
883
894
|
matter by this rule, specify `""` for `front_matter_title`.
|
|
884
895
|
|
|
885
|
-
Rationale: A top
|
|
896
|
+
Rationale: A top-level heading is an h1 on the first line of the file, and
|
|
886
897
|
serves as the title for the document. If this convention is in use, then there
|
|
887
898
|
can not be more than one title for the document, and the entire document
|
|
888
899
|
should be contained within this heading.
|
|
@@ -895,7 +906,7 @@ Tags: headings, headers
|
|
|
895
906
|
|
|
896
907
|
Aliases: no-trailing-punctuation
|
|
897
908
|
|
|
898
|
-
Parameters: punctuation (string; default "
|
|
909
|
+
Parameters: punctuation (string; default ".,;:!。,;:!")
|
|
899
910
|
|
|
900
911
|
Fixable: Most violations can be fixed by tooling
|
|
901
912
|
|
|
@@ -914,10 +925,15 @@ To fix this, remove the trailing punctuation:
|
|
|
914
925
|
|
|
915
926
|
Note: The `punctuation` parameter can be used to specify what characters count
|
|
916
927
|
as punctuation at the end of a heading. For example, you can change it to
|
|
917
|
-
`"
|
|
928
|
+
`".,;:"` to allow headings that end with an exclamation point. `?` is
|
|
929
|
+
allowed by default because of how common it is in headings of FAQ-style documents.
|
|
918
930
|
Setting the `punctuation` parameter to `""` allows all characters - and is
|
|
919
931
|
equivalent to disabling the rule.
|
|
920
932
|
|
|
933
|
+
Note: The trailing semicolon of
|
|
934
|
+
[HTML entity references](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references)
|
|
935
|
+
like `©`, `©`, and `©` is ignored by this rule.
|
|
936
|
+
|
|
921
937
|
Rationale: Headings are not meant to be full sentences. More information:
|
|
922
938
|
<https://cirosantilli.com/markdown-style-guide#punctuation-at-the-end-of-headers>
|
|
923
939
|
|
|
@@ -935,7 +951,7 @@ This rule is triggered when blockquotes have more than one space after the
|
|
|
935
951
|
blockquote (`>`) symbol:
|
|
936
952
|
|
|
937
953
|
```markdown
|
|
938
|
-
> This is a
|
|
954
|
+
> This is a blockquote with bad indentation
|
|
939
955
|
> there should only be one.
|
|
940
956
|
```
|
|
941
957
|
|
|
@@ -956,8 +972,6 @@ Tags: blockquote, whitespace
|
|
|
956
972
|
|
|
957
973
|
Aliases: no-blanks-blockquote
|
|
958
974
|
|
|
959
|
-
Fixable: Most violations can be fixed by tooling
|
|
960
|
-
|
|
961
975
|
This rule is triggered when two blockquote blocks are separated by nothing
|
|
962
976
|
except for a blank line:
|
|
963
977
|
|
|
@@ -1005,7 +1019,7 @@ Parameters: style ("one", "ordered", "one_or_ordered", "zero"; default "one_or_o
|
|
|
1005
1019
|
|
|
1006
1020
|
This rule is triggered for ordered lists that do not either start with '1.' or
|
|
1007
1021
|
do not have a prefix that increases in numerical order (depending on the
|
|
1008
|
-
configured style). The less-common
|
|
1022
|
+
configured style). The less-common pattern of using '0.' as a first prefix or
|
|
1009
1023
|
for all prefixes is also supported.
|
|
1010
1024
|
|
|
1011
1025
|
Example valid list if the style is configured as 'one':
|
|
@@ -1058,8 +1072,9 @@ This rule supports 0-prefixing ordered list items for uniform indentation:
|
|
|
1058
1072
|
...
|
|
1059
1073
|
```
|
|
1060
1074
|
|
|
1061
|
-
Note: This rule will report violations for cases like the following where an
|
|
1062
|
-
|
|
1075
|
+
Note: This rule will report violations for cases like the following where an
|
|
1076
|
+
improperly-indented code block (or similar) appears between two list items and
|
|
1077
|
+
"breaks" the list in two:
|
|
1063
1078
|
|
|
1064
1079
|
<!-- markdownlint-disable code-fence-style -->
|
|
1065
1080
|
|
|
@@ -1073,7 +1088,8 @@ Code block
|
|
|
1073
1088
|
1. Second list
|
|
1074
1089
|
~~~
|
|
1075
1090
|
|
|
1076
|
-
The fix is to indent the code block so it becomes part of the preceding list
|
|
1091
|
+
The fix is to indent the code block so it becomes part of the preceding list
|
|
1092
|
+
item as intended:
|
|
1077
1093
|
|
|
1078
1094
|
~~~markdown
|
|
1079
1095
|
1. First list
|
|
@@ -1085,7 +1101,7 @@ The fix is to indent the code block so it becomes part of the preceding list ite
|
|
|
1085
1101
|
2. Still first list
|
|
1086
1102
|
~~~
|
|
1087
1103
|
|
|
1088
|
-
<!-- markdownlint-
|
|
1104
|
+
<!-- markdownlint-restore -->
|
|
1089
1105
|
|
|
1090
1106
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
1091
1107
|
|
|
@@ -1123,7 +1139,7 @@ default is 1 space after any list marker:
|
|
|
1123
1139
|
|
|
1124
1140
|
A document style may change the number of spaces after unordered list items
|
|
1125
1141
|
and ordered list items independently, as well as based on whether the content
|
|
1126
|
-
of every item in the list consists of a single paragraph
|
|
1142
|
+
of every item in the list consists of a single paragraph or multiple
|
|
1127
1143
|
paragraphs (including sub-lists and code blocks).
|
|
1128
1144
|
|
|
1129
1145
|
For example, the style guide at
|
|
@@ -1159,7 +1175,7 @@ or
|
|
|
1159
1175
|
1. Bar
|
|
1160
1176
|
```
|
|
1161
1177
|
|
|
1162
|
-
To fix this, ensure the correct number of spaces are used after list marker
|
|
1178
|
+
To fix this, ensure the correct number of spaces are used after the list marker
|
|
1163
1179
|
for your selected document style.
|
|
1164
1180
|
|
|
1165
1181
|
Rationale: Violations of this rule can lead to improperly rendered content.
|
|
@@ -1367,7 +1383,7 @@ or match the given style if the rule is so configured:
|
|
|
1367
1383
|
```
|
|
1368
1384
|
|
|
1369
1385
|
Note: by default, this rule is configured to just require that all horizontal
|
|
1370
|
-
rules in the document are the same
|
|
1386
|
+
rules in the document are the same and will trigger if any of the horizontal
|
|
1371
1387
|
rules are different than the first one encountered in the document. If you
|
|
1372
1388
|
want to configure the rule to match a specific style, the parameter given to
|
|
1373
1389
|
the 'style' option is a string containing the exact horizontal rule text that
|
|
@@ -1411,7 +1427,7 @@ Lorem ipsum dolor sit amet...
|
|
|
1411
1427
|
Consectetur adipiscing elit, sed do eiusmod.
|
|
1412
1428
|
```
|
|
1413
1429
|
|
|
1414
|
-
Note: This rule looks for single
|
|
1430
|
+
Note: This rule looks for single-line paragraphs that consist entirely
|
|
1415
1431
|
of emphasized text. It won't fire on emphasis used within regular text,
|
|
1416
1432
|
multi-line emphasized paragraphs, or paragraphs ending in punctuation
|
|
1417
1433
|
(normal or full-width). Similarly to rule MD026, you can configure what
|
|
@@ -1457,7 +1473,7 @@ Here is some more _italic_ text.
|
|
|
1457
1473
|
```
|
|
1458
1474
|
|
|
1459
1475
|
Rationale: Emphasis is only parsed as such when the asterisks/underscores
|
|
1460
|
-
aren't
|
|
1476
|
+
aren't surrounded by spaces. This rule attempts to detect where
|
|
1461
1477
|
they were surrounded by spaces, but it appears that emphasized text was
|
|
1462
1478
|
intended by the author.
|
|
1463
1479
|
|
|
@@ -1493,7 +1509,7 @@ automatically trimmed (to allow for embedded backticks):
|
|
|
1493
1509
|
`` `backticks` ``
|
|
1494
1510
|
```
|
|
1495
1511
|
|
|
1496
|
-
Note: A single leading or trailing space is allowed if used to separate
|
|
1512
|
+
Note: A single leading or trailing space is allowed if used to separate code span
|
|
1497
1513
|
markers from an embedded backtick:
|
|
1498
1514
|
|
|
1499
1515
|
```markdown
|
|
@@ -1559,39 +1575,49 @@ correct syntax highlighting for code. More information:
|
|
|
1559
1575
|
|
|
1560
1576
|
<a name="md041"></a>
|
|
1561
1577
|
|
|
1562
|
-
## MD041 - First line in file should be a top
|
|
1578
|
+
## MD041 - First line in a file should be a top-level heading
|
|
1563
1579
|
|
|
1564
1580
|
Tags: headings, headers
|
|
1565
1581
|
|
|
1566
1582
|
Aliases: first-line-heading, first-line-h1
|
|
1567
1583
|
|
|
1568
|
-
Parameters: level, front_matter_title (number; default 1, string; default "^\s*title
|
|
1584
|
+
Parameters: level, front_matter_title (number; default 1, string; default "^\s*"?title"?\s*[:=]")
|
|
1569
1585
|
|
|
1570
1586
|
This rule is intended to ensure documents have a title and is triggered when
|
|
1571
|
-
the first line in the file isn't a top
|
|
1587
|
+
the first line in the file isn't a top-level (h1) heading:
|
|
1572
1588
|
|
|
1573
1589
|
```markdown
|
|
1574
1590
|
This is a file without a heading
|
|
1575
1591
|
```
|
|
1576
1592
|
|
|
1577
|
-
To fix this, add a top
|
|
1593
|
+
To fix this, add a top-level heading to the beginning of the file:
|
|
1578
1594
|
|
|
1579
1595
|
```markdown
|
|
1580
1596
|
# File with heading
|
|
1581
1597
|
|
|
1582
|
-
This is a file with a top
|
|
1598
|
+
This is a file with a top-level heading
|
|
1599
|
+
```
|
|
1600
|
+
|
|
1601
|
+
Because it is common for projects on GitHub to use an image for the heading of
|
|
1602
|
+
`README.md` and that is not well-supported by Markdown, HTML headings are also
|
|
1603
|
+
permitted by this rule. For example:
|
|
1604
|
+
|
|
1605
|
+
```markdown
|
|
1606
|
+
<h1 align="center"><img src="https://placekitten.com/300/150"/></h1>
|
|
1607
|
+
|
|
1608
|
+
This is a file with a top-level HTML heading
|
|
1583
1609
|
```
|
|
1584
1610
|
|
|
1585
|
-
Note: The `level` parameter can be used to change the top
|
|
1586
|
-
where
|
|
1611
|
+
Note: The `level` parameter can be used to change the top-level (ex: to h2) in cases
|
|
1612
|
+
where an h1 is added externally.
|
|
1587
1613
|
|
|
1588
|
-
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
|
1589
|
-
`title` property (commonly used with blog posts), this rule will not
|
|
1590
|
-
violation. To use a different property name in front matter,
|
|
1591
|
-
of a regular expression via the `front_matter_title` parameter.
|
|
1592
|
-
use of front matter by this rule, specify `""` for `front_matter_title`.
|
|
1614
|
+
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
|
1615
|
+
contains a `title` property (commonly used with blog posts), this rule will not
|
|
1616
|
+
report a violation. To use a different property name in the front matter,
|
|
1617
|
+
specify the text of a regular expression via the `front_matter_title` parameter.
|
|
1618
|
+
To disable the use of front matter by this rule, specify `""` for `front_matter_title`.
|
|
1593
1619
|
|
|
1594
|
-
Rationale: The top
|
|
1620
|
+
Rationale: The top-level heading often acts as the title of a document. More
|
|
1595
1621
|
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
|
1596
1622
|
|
|
1597
1623
|
<a name="md042"></a>
|
|
@@ -1672,8 +1698,9 @@ To allow optional headings as with the following structure:
|
|
|
1672
1698
|
### Notes (optional)
|
|
1673
1699
|
```
|
|
1674
1700
|
|
|
1675
|
-
Use the special value `"*"` meaning "
|
|
1676
|
-
|
|
1701
|
+
Use the special value `"*"` meaning "zero or more unspecified headings" or the
|
|
1702
|
+
special value `"+"` meaning "one or more unspecified headings" and set the
|
|
1703
|
+
`headings` parameter to:
|
|
1677
1704
|
|
|
1678
1705
|
```json
|
|
1679
1706
|
[
|
|
@@ -1752,7 +1779,7 @@ Or with reference syntax as:
|
|
|
1752
1779
|
|
|
1753
1780
|
Guidance for writing alternate text is available from the [W3C](https://www.w3.org/WAI/alt/),
|
|
1754
1781
|
[Wikipedia](https://en.wikipedia.org/wiki/Alt_attribute), and
|
|
1755
|
-
[other locations](https://www.phase2technology.com/blog/no-more-excuses
|
|
1782
|
+
[other locations](https://www.phase2technology.com/blog/no-more-excuses).
|
|
1756
1783
|
|
|
1757
1784
|
Rationale: Alternate text is important for accessibility and describes the
|
|
1758
1785
|
content of an image for people who may not be able to see it.
|
|
@@ -1786,12 +1813,13 @@ In the default configuration this rule reports a violation for the following doc
|
|
|
1786
1813
|
|
|
1787
1814
|
More text.
|
|
1788
1815
|
|
|
1789
|
-
<!-- markdownlint-
|
|
1816
|
+
<!-- markdownlint-restore -->
|
|
1790
1817
|
|
|
1791
|
-
To fix violations of this rule, use a consistent style (either indenting or code
|
|
1818
|
+
To fix violations of this rule, use a consistent style (either indenting or code
|
|
1819
|
+
fences).
|
|
1792
1820
|
|
|
1793
|
-
The specified style can be specific (`fenced`, `indented`) or simply require
|
|
1794
|
-
be consistent within the document (`consistent`).
|
|
1821
|
+
The specified style can be specific (`fenced`, `indented`) or simply require
|
|
1822
|
+
that usage be consistent within the document (`consistent`).
|
|
1795
1823
|
|
|
1796
1824
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
1797
1825
|
|
|
@@ -1805,9 +1833,10 @@ Aliases: single-trailing-newline
|
|
|
1805
1833
|
|
|
1806
1834
|
Fixable: Most violations can be fixed by tooling
|
|
1807
1835
|
|
|
1808
|
-
This rule is triggered when there is not a single newline character at the end
|
|
1836
|
+
This rule is triggered when there is not a single newline character at the end
|
|
1837
|
+
of a file.
|
|
1809
1838
|
|
|
1810
|
-
|
|
1839
|
+
An example that triggers the rule:
|
|
1811
1840
|
|
|
1812
1841
|
```markdown
|
|
1813
1842
|
# Heading
|
|
@@ -1837,7 +1866,8 @@ Aliases: code-fence-style
|
|
|
1837
1866
|
|
|
1838
1867
|
Parameters: style ("consistent", "tilde", "backtick"; default "consistent")
|
|
1839
1868
|
|
|
1840
|
-
This rule is triggered when the symbols used in the document for fenced code
|
|
1869
|
+
This rule is triggered when the symbols used in the document for fenced code
|
|
1870
|
+
blocks do not match the configured code fence style:
|
|
1841
1871
|
|
|
1842
1872
|
````markdown
|
|
1843
1873
|
```ruby
|
package/helpers/LICENSE
CHANGED