mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-23 17:30:12 +01:00
Reimplement MD003/heading-style using micromark tokens.
This commit is contained in:
parent
e447db33c9
commit
6daaa43410
10 changed files with 132 additions and 148 deletions
|
|
@ -309,6 +309,26 @@ function getHeadingLevel(heading) {
|
|||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the heading style of a Micromark heading tokan.
|
||||
*
|
||||
* @param {Token} heading Micromark heading token.
|
||||
* @returns {"atx" | "atx_closed" | "setext"} Heading style.
|
||||
*/
|
||||
function getHeadingStyle(heading) {
|
||||
if (heading.type === "setextHeading") {
|
||||
return "setext";
|
||||
}
|
||||
const atxHeadingSequenceLength = filterByTypes(
|
||||
heading.children,
|
||||
[ "atxHeadingSequence" ]
|
||||
).length;
|
||||
if (atxHeadingSequenceLength === 1) {
|
||||
return "atx";
|
||||
}
|
||||
return "atx_closed";
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML tag information.
|
||||
*
|
||||
|
|
@ -433,6 +453,7 @@ module.exports = {
|
|||
filterByPredicate,
|
||||
filterByTypes,
|
||||
getHeadingLevel,
|
||||
getHeadingStyle,
|
||||
getHtmlTagInfo,
|
||||
getMicromarkEvents,
|
||||
getTokenParentOfType,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue