mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00: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
|
|
@ -3,6 +3,7 @@
|
|||
"use strict";
|
||||
|
||||
const { URL } = require("url");
|
||||
const { filterTokens } = require("../../helpers");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote" ],
|
||||
|
|
@ -12,10 +13,8 @@ module.exports = {
|
|||
"/blob/master/test/rules/any-blockquote.js"
|
||||
),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
return token.type === "blockquote_open";
|
||||
}).forEach(function forToken(blockquote) {
|
||||
"function": (params, onError) => {
|
||||
filterTokens(params, "blockquote_open", (blockquote) => {
|
||||
const lines = blockquote.map[1] - blockquote.map[0];
|
||||
onError({
|
||||
"lineNumber": blockquote.lineNumber,
|
||||
|
|
|
|||
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { forEachLine, getLineMetadata } = require("../../helpers");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "every-n-lines" ],
|
||||
"description": "Rule that reports an error every N lines",
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
"function": (params, onError) => {
|
||||
const n = params.config.n || 2;
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
forEachLine(getLineMetadata(params), (line, lineIndex) => {
|
||||
const lineNumber = lineIndex + 1;
|
||||
if ((lineNumber % n) === 0) {
|
||||
onError({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue