diff options
Diffstat (limited to 'doc/.markdownlint/rules/tabs_blank_lines.js')
-rw-r--r-- | doc/.markdownlint/rules/tabs_blank_lines.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/.markdownlint/rules/tabs_blank_lines.js b/doc/.markdownlint/rules/tabs_blank_lines.js new file mode 100644 index 00000000000..e0e2c1a0a9b --- /dev/null +++ b/doc/.markdownlint/rules/tabs_blank_lines.js @@ -0,0 +1,26 @@ +const { globalPath } = require('../require_helper'); +const { + forEachLine, + getLineMetadata, + isBlankLine, +} = require(`${globalPath}/markdownlint-rule-helpers`); + +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, + }); + } + }); + }, +}; |