Skip to main content

Module blank_lines

Module blank_lines 

Source
Expand description

What counts as a blank line for the rules that require blank lines around a construct (MD022, MD031, MD032, MD058).

Those rules exist so a reader can see where one block ends and the next begins, and a line holding nothing but an HTML comment separates two blocks as plainly as an empty one does. CommonMark disagrees - a comment is an HTML block of type 2 that ends on the line carrying -->, so the construct below it really does start with no blank line between them - but reporting that costs more than it is worth: the fix inserts a blank line, and for a directive comment (<!-- prettier-ignore -->, <!-- markdownlint-disable -->, a generator’s own trigger) adjacency is the meaning, so rewriting the document turns the directive off. rumdl treats such a line as blank instead. (#866)

The odd corners are deliberate and match markdownlint’s isBlankLine, whose convention this is: an unclosed <!-- and a bare --> each count, which is what makes a comment spanning several lines work, and > characters are removed so the whole convention holds inside a blockquote.

Functions§

is_blank_or_comment_only
Whether a line contributes nothing but HTML comments, and so separates the blocks around it the way an empty line does.