mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
This commit is contained in:
parent
4a52864b39
commit
a563c082a5
11 changed files with 228 additions and 12 deletions
27
lib/md055.js
Normal file
27
lib/md055.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD055", "table-missing-border" ],
|
||||
"description": "Table is missing leading or trailing pipe character",
|
||||
"tags": [ "table" ],
|
||||
"function": function MD055(params, onError) {
|
||||
const tables = filterByTypes(params.parsers.micromark.tokens, [ "table" ]);
|
||||
for (const table of tables) {
|
||||
const rows = filterByTypes(table.children, [ "tableRow", "tableDelimiterRow" ]);
|
||||
for (const row of rows) {
|
||||
const { startLine, text } = row;
|
||||
if (!text.startsWith("|")) {
|
||||
addErrorContext(onError, startLine, text, true);
|
||||
}
|
||||
if (!text.endsWith("|")) {
|
||||
addErrorContext(onError, startLine, text, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue