2023-04-23 21:23:45 +05:30
|
|
|
const { forEachLine, getLineMetadata, isBlankLine } = require(`markdownlint-rule-helpers`);
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
names: ['tabs-blank-lines'],
|
|
|
|
description: 'Tab elements must be surrounded by blank lines',
|
|
|
|
tags: ['gitlab-docs', 'tabs'],
|
|
|
|
function: (params, onError) => {
|
|
|
|
const tabElements = ['::Tabs', '::EndTabs', ':::TabTitle'];
|
|
|
|
forEachLine(getLineMetadata(params), (line, lineIndex) => {
|
|
|
|
const lineHasTab = tabElements.includes(line.split(' ')[0]);
|
|
|
|
const prevLine = params.lines[lineIndex - 1];
|
|
|
|
const nextLine = params.lines[lineIndex + 1];
|
|
|
|
|
|
|
|
if (lineHasTab && (!isBlankLine(prevLine) || !isBlankLine(nextLine))) {
|
|
|
|
onError({
|
|
|
|
lineNumber: lineIndex + 1,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|