2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2018-04-27 22:05:34 -07:00
|
|
|
const shared = require("./shared");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
"names": [ "MD031", "blanks-around-fences" ],
|
|
|
|
"description": "Fenced code blocks should be surrounded by blank lines",
|
|
|
|
"tags": [ "code", "blank_lines" ],
|
|
|
|
"function": function MD031(params, onError) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const lines = params.lines;
|
2018-03-04 23:06:31 -08:00
|
|
|
shared.forEachLine(function forLine(line, i, inCode, onFence) {
|
2018-01-21 21:44:25 -08:00
|
|
|
if (((onFence > 0) && (i - 1 >= 0) && lines[i - 1].length) ||
|
|
|
|
((onFence < 0) && (i + 1 < lines.length) && lines[i + 1].length)) {
|
|
|
|
shared.addErrorContext(onError, i + 1, lines[i].trim());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|