You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/no-multiple-h1.md
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ An H1 heading is meant to define the main heading of a page, providing important
10
10
11
11
This rule warns when it finds more than one H1 heading in a Markdown document. It checks for:
12
12
13
-
- ATX-style headings (`# Heading`)
13
+
- ATX-style headings (`# Heading` or `# Heading #`)
14
14
- Setext-style headings (`Heading\n=========`)
15
-
- Front matter title fields (YAMLand TOML)
15
+
- Front matter title fields ([YAML](https://yaml.org/), [TOML](https://toml.io/en/), and [JSON](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/JSON))
16
16
- HTML h1 tags (`<h1>Heading</h1>`)
17
17
18
18
Examples of **incorrect** code for this rule:
@@ -46,7 +46,7 @@ Another H1 heading
46
46
47
47
The following options are available on this rule:
48
48
49
-
*`frontmatterTitle: string` - A regex pattern to match title fields in front matter. The default pattern matches both YAML (`title:`) and TOML (`title =`) formats. Set to an empty string to disable front matter title checking.
49
+
*`frontmatterTitle: string` - A regex pattern to match title fields in front matter. The default pattern matches both YAML (`title:`), TOML (`title =`), and JSON (`"title":`) formats. Set to an empty string to disable front matter title checking.
50
50
51
51
Examples of **incorrect** code for this rule:
52
52
@@ -57,7 +57,27 @@ Examples of **incorrect** code for this rule:
57
57
title: My Title
58
58
---
59
59
60
-
# Heading 1
60
+
# Heading 1 with YAML front matter
61
+
```
62
+
63
+
```markdown
64
+
<!-- eslint markdown/no-multiple-h1: "error" -->
65
+
66
+
+++
67
+
title = "My Title"
68
+
+++
69
+
70
+
# Heading 1 with TOML front matter
71
+
```
72
+
73
+
```markdown
74
+
<!-- eslint markdown/no-multiple-h1: "error" -->
75
+
76
+
---
77
+
{ "title": "My Title" }
78
+
---
79
+
80
+
# Heading 1 with JSON front matter
61
81
```
62
82
63
83
Examples of **incorrect** code when configured as `"no-multiple-h1": ["error", { frontmatterTitle: "\\s*heading\\s*[:=]" }]`:
0 commit comments