DavidAnson / markdownlint

A Node.js style checker and lint tool for Markdown/CommonMark files.
MIT License
4.84k stars 736 forks source link

MD025 does not trigger when first lines are empty and/or comments #1420

Open xefiry opened 1 week ago

xefiry commented 1 week ago

The error MD025 "Multiple top-level headings in the same document" should trigger when there is more than one heading level 1 in the document.

However, if there are empty and/or comment lines before the first heading, the error does not trigger.

Example with an empty line and a comment


<!-- omit in toc -->
# Title

- [Foo](#foo)

# Foo

In this example, the comment is to ignore Title in the generation of the table of content by the extension Markdown All in One, but any comment will do.

The error can be reproduced with any amount of comment lines or empty lines before the first heading.

DavidAnson commented 1 week ago

This rule is behaving as documented (a top level heading must be on the first line), but I agree that being preceeded by a blank line doesn't seem like it should disable the rule.

https://github.com/DavidAnson/markdownlint/blob/main/doc/md025.md