mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
21 lines
697 B
JavaScript
21 lines
697 B
JavaScript
// @ts-check
|
|
|
|
"use strict";
|
|
|
|
const shared = require("./shared");
|
|
const { addErrorContext, filterTokens, isBlankLine } = shared;
|
|
|
|
module.exports = {
|
|
"names": [ "MD022", "blanks-around-headings", "blanks-around-headers" ],
|
|
"description": "Headings should be surrounded by blank lines",
|
|
"tags": [ "headings", "headers", "blank_lines" ],
|
|
"function": function MD022(params, onError) {
|
|
const { lines } = params;
|
|
filterTokens(params, "heading_open", (token) => {
|
|
const [ topIndex, nextIndex ] = token.map;
|
|
if (!isBlankLine(lines[topIndex - 1]) || !isBlankLine(lines[nextIndex])) {
|
|
addErrorContext(onError, topIndex + 1, lines[topIndex].trim());
|
|
}
|
|
});
|
|
}
|
|
};
|