mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Expose shared.js helper code for custom rule authors (fixes #134).
This commit is contained in:
parent
f614f3e1ce
commit
7e980401b8
52 changed files with 283 additions and 184 deletions
13
lib/md014.js
13
lib/md014.js
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, filterTokens, newLineRe, rangeFromRegExp } =
|
||||
require("../helpers");
|
||||
|
||||
const dollarCommandRe = /^(\s*)(\$\s)/;
|
||||
|
||||
|
|
@ -12,15 +13,15 @@ module.exports = {
|
|||
"tags": [ "code" ],
|
||||
"function": function MD014(params, onError) {
|
||||
[ "code_block", "fence" ].forEach(function forType(type) {
|
||||
shared.filterTokens(params, type, function forToken(token) {
|
||||
filterTokens(params, type, function forToken(token) {
|
||||
let allBlank = true;
|
||||
if (token.content && token.content.split(shared.newLineRe)
|
||||
if (token.content && token.content.split(newLineRe)
|
||||
.every(function forLine(line) {
|
||||
return !line || (allBlank = false) || dollarCommandRe.test(line);
|
||||
}) && !allBlank) {
|
||||
shared.addErrorContext(onError, token.lineNumber,
|
||||
token.content.split(shared.newLineRe)[0].trim(), null, null,
|
||||
shared.rangeFromRegExp(token.line, dollarCommandRe));
|
||||
addErrorContext(onError, token.lineNumber,
|
||||
token.content.split(newLineRe)[0].trim(), null, null,
|
||||
rangeFromRegExp(token.line, dollarCommandRe));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue