mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +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
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorDetailIf, filterTokens, headingStyleFor } =
|
||||
require("../helpers");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD003", "heading-style", "header-style" ],
|
||||
|
|
@ -10,8 +11,8 @@ module.exports = {
|
|||
"tags": [ "headings", "headers" ],
|
||||
"function": function MD003(params, onError) {
|
||||
let style = params.config.style || "consistent";
|
||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||
const styleForToken = shared.headingStyleFor(token);
|
||||
filterTokens(params, "heading_open", function forToken(token) {
|
||||
const styleForToken = headingStyleFor(token);
|
||||
if (style === "consistent") {
|
||||
style = styleForToken;
|
||||
}
|
||||
|
|
@ -32,7 +33,7 @@ module.exports = {
|
|||
} else if (style === "setext_with_atx_closed") {
|
||||
expected = h12 ? "setext" : "atx_closed";
|
||||
}
|
||||
shared.addErrorDetailIf(onError, token.lineNumber,
|
||||
addErrorDetailIf(onError, token.lineNumber,
|
||||
expected, styleForToken);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue