|
| 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 |
0 commit comments