Skip to content

Commit 713322e

Browse files
author
merge-queue-bot
committed
Merge PR #218: Add MDS044 horizontal-rule-style rule
2 parents ed3c39e + 14da794 commit 713322e

23 files changed

Lines changed: 1005 additions & 18 deletions

.claude/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,19 @@
3131
],
3232
"ask": [
3333
]
34+
},
35+
"hooks": {
36+
"PostToolUse": [
37+
{
38+
"matcher": "Bash",
39+
"hooks": [
40+
{
41+
"type": "command",
42+
"command": "jq -re '.tool_input.command // \"\"' | grep -q 'git push' && REPO=$(git remote get-url origin 2>/dev/null | sed -E 's|.*[:/]([^/]+/[^/]+?)(\\.git)?$|\\1|') && BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) && PR=$(gh api \"repos/$REPO/pulls\" 2>/dev/null | jq -r --arg b \"$BRANCH\" '.[] | select(.head.ref == $b) | .number' | head -1) && [ -n \"$PR\" ] && gh api \"repos/$REPO/pulls/$PR/requested_reviewers\" -X POST -f 'reviewers[]=copilot-pull-request-reviewer[bot]' 2>/dev/null; true",
43+
"statusMessage": "Requesting code review..."
44+
}
45+
]
46+
}
47+
]
3448
}
3549
}

PLAN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ footer: |
2424
| 105 || sonnet | [No inline HTML rule](plan/105_no-inline-html.md) |
2525
| 106 || sonnet | [Emphasis style rule](plan/106_emphasis-style.md) |
2626
| 107 || opus | [No reference-style links rule](plan/107_no-reference-style.md) |
27-
| 108 | 🔲 | sonnet | [Horizontal rule style rule](plan/108_horizontal-rule-style.md) |
27+
| 108 | | sonnet | [Horizontal rule style rule](plan/108_horizontal-rule-style.md) |
2828
| 109 || sonnet | [List marker style rule](plan/109_list-marker-style.md) |
2929
| 110 || sonnet | [Ordered list numbering rule](plan/110_ordered-list-numbering.md) |
3030
| 111 || sonnet | [Ambiguous emphasis rule](plan/111_ambiguous-emphasis.md) |

cmd/mdsmith/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
_ "github.com/jeduden/mdsmith/internal/rules/githooksync"
4242
_ "github.com/jeduden/mdsmith/internal/rules/headingincrement"
4343
_ "github.com/jeduden/mdsmith/internal/rules/headingstyle"
44+
_ "github.com/jeduden/mdsmith/internal/rules/horizontalrulestyle"
4445
_ "github.com/jeduden/mdsmith/internal/rules/include"
4546
_ "github.com/jeduden/mdsmith/internal/rules/linelength"
4647
_ "github.com/jeduden/mdsmith/internal/rules/listindent"

internal/integration/rules_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
_ "github.com/jeduden/mdsmith/internal/rules/githooksync"
3434
_ "github.com/jeduden/mdsmith/internal/rules/headingincrement"
3535
_ "github.com/jeduden/mdsmith/internal/rules/headingstyle"
36+
_ "github.com/jeduden/mdsmith/internal/rules/horizontalrulestyle"
3637
_ "github.com/jeduden/mdsmith/internal/rules/include"
3738
_ "github.com/jeduden/mdsmith/internal/rules/linelength"
3839
_ "github.com/jeduden/mdsmith/internal/rules/listindent"
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
---
2+
id: MDS044
3+
name: horizontal-rule-style
4+
status: ready
5+
description: >-
6+
Thematic breaks must use a consistent delimiter style, exact
7+
length, and blank-line spacing.
8+
---
9+
# MDS044: horizontal-rule-style
10+
11+
Thematic breaks must use a consistent delimiter style, exact
12+
length, and blank-line spacing.
13+
14+
CommonMark accepts `---`, `***`, and `___` with any length ≥ 3
15+
and optional internal spaces. This rule pins one delimiter,
16+
enforces an exact length, and requires surrounding blank lines
17+
so `---` cannot be confused with a setext heading underline.
18+
19+
## Settings
20+
21+
| Setting | Type | Default | Description |
22+
|-----------------------|--------|----------|-----------------------------------------------------------------------------------------|
23+
| `style` | string | `"dash"` | Delimiter character: `"dash"` (`---`), `"asterisk"` (`***`), or `"underscore"` (`___`). |
24+
| `length` | int | `3` | Exact number of delimiter characters required (minimum 3). |
25+
| `require-blank-lines` | bool | `true` | Blank lines must appear before and after each thematic break. |
26+
27+
## Config
28+
29+
Enable with defaults:
30+
31+
```yaml
32+
rules:
33+
horizontal-rule-style:
34+
style: dash
35+
length: 3
36+
require-blank-lines: true
37+
```
38+
39+
Disable:
40+
41+
```yaml
42+
rules:
43+
horizontal-rule-style: false
44+
```
45+
46+
Custom (asterisk style, length 5):
47+
48+
```yaml
49+
rules:
50+
horizontal-rule-style:
51+
style: asterisk
52+
length: 5
53+
```
54+
55+
## Diagnostics
56+
57+
```text
58+
horizontal rule uses {actual}; configured style is {expected}
59+
horizontal rule has internal spaces
60+
horizontal rule has length {actual}; configured length is {expected}
61+
horizontal rule needs a blank line above
62+
horizontal rule needs a blank line below
63+
```
64+
65+
## Examples
66+
67+
### Good (default settings)
68+
69+
<?include
70+
file: good/default.md
71+
wrap: markdown
72+
?>
73+
74+
```markdown
75+
# Test Document
76+
77+
Some text before.
78+
79+
---
80+
81+
Some text after.
82+
```
83+
84+
<?/include?>
85+
86+
### Good (asterisk style)
87+
88+
<?include
89+
file: good/asterisk.md
90+
wrap: markdown
91+
?>
92+
93+
```markdown
94+
# Test Document
95+
96+
Some text before.
97+
98+
***
99+
100+
Some text after.
101+
```
102+
103+
<?/include?>
104+
105+
### Bad (wrong delimiter)
106+
107+
<?include
108+
file: bad/wrong-delimiter.md
109+
wrap: markdown
110+
?>
111+
112+
```markdown
113+
# Test Document
114+
115+
Some text before.
116+
117+
***
118+
119+
Some text after.
120+
```
121+
122+
<?/include?>
123+
124+
### Bad (internal spaces)
125+
126+
<?include
127+
file: bad/internal-spaces.md
128+
wrap: markdown
129+
?>
130+
131+
```markdown
132+
# Test Document
133+
134+
Some text before.
135+
136+
- - -
137+
138+
Some text after.
139+
```
140+
141+
<?/include?>
142+
143+
### Bad (wrong length)
144+
145+
<?include
146+
file: bad/wrong-length.md
147+
wrap: markdown
148+
?>
149+
150+
```markdown
151+
# Test Document
152+
153+
Some text before.
154+
155+
-----
156+
157+
Some text after.
158+
```
159+
160+
<?/include?>
161+
162+
### Bad (missing blank line above)
163+
164+
<?include
165+
file: bad/no-blank-above.md
166+
wrap: markdown
167+
?>
168+
169+
```markdown
170+
# Test Document
171+
---
172+
173+
Text after.
174+
```
175+
176+
<?/include?>
177+
178+
### Bad (missing blank line below)
179+
180+
<?include
181+
file: bad/no-blank-below.md
182+
wrap: markdown
183+
?>
184+
185+
```markdown
186+
# Test Document
187+
188+
---
189+
Text after.
190+
```
191+
192+
<?/include?>
193+
194+
## Auto-fix
195+
196+
The rule rewrites each thematic break to the canonical form
197+
(`style` repeated `length` times). It also inserts any missing
198+
blank lines above and below.
199+
200+
## Meta-Information
201+
202+
- **ID**: MDS044
203+
- **Name**: `horizontal-rule-style`
204+
- **Status**: ready
205+
- **Default**: disabled
206+
- **Fixable**: yes
207+
- **Implementation**:
208+
[source](./)
209+
- **Category**: whitespace
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
diagnostics:
3+
- line: 5
4+
column: 1
5+
message: "horizontal rule has internal spaces"
6+
---
7+
# Test Document
8+
9+
Some text before.
10+
11+
- - -
12+
13+
Some text after.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
diagnostics:
3+
- line: 2
4+
column: 1
5+
message: "horizontal rule needs a blank line above"
6+
---
7+
# Test Document
8+
---
9+
10+
Text after.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
diagnostics:
3+
- line: 3
4+
column: 1
5+
message: "horizontal rule needs a blank line below"
6+
---
7+
# Test Document
8+
9+
---
10+
Text after.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
diagnostics:
3+
- line: 5
4+
column: 1
5+
message: "horizontal rule uses asterisk; configured style is dash"
6+
---
7+
# Test Document
8+
9+
Some text before.
10+
11+
***
12+
13+
Some text after.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
diagnostics:
3+
- line: 5
4+
column: 1
5+
message: "horizontal rule has length 5; configured length is 3"
6+
---
7+
# Test Document
8+
9+
Some text before.
10+
11+
-----
12+
13+
Some text after.

0 commit comments

Comments
 (0)