Repository navigation
Commit e897556
authored
fix(md012): report blank lines before a code block that ends the document (#791)
MD012 walks the document through `filtered_lines()` with `skip_code_blocks()`,
so a blank run sitting immediately before a code block is only flushed by the
skip detector, which fires on the next filtered line after the skipped region.
When the code block runs to the end of the file there is no next filtered line,
and the EOF handler is guarded by `last_line_is_blank`, false here because the
last line is the closing fence, so the accumulated run is discarded.
printf '# Install\n\nRun this:\n\n\n```bash\nnpm install\n```\n' > s.md
rumdl check -e MD012 s.md # Success: No issues found
Appending "\nDone.\n" to the same file reports the run at line 5. The blank run
is identical; only whether the fenced block is the last block in the file
differs. An indented code block at EOF behaves the same way, and the divergence
is visible under the default rule set, not only with `-e MD012`.
Flush the pending run after the loop when the last line is not blank, using the
same effective maximum the in-loop skip handling uses, so a code block at EOF is
treated like any other skipped region. Trailing-blank handling is untouched: the
two branches are mutually exclusive on `last_line_is_blank`.1 parent 6962184 commit e897556
2 files changed
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
318 | 338 | | |
319 | 339 | | |
320 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
0 commit comments