mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Reimplement MD041/first-line-heading/first-line-h1 using micromark tokens.
This commit is contained in:
parent
0f5e65abd4
commit
a83e2d8a09
4 changed files with 94 additions and 80 deletions
|
|
@ -309,11 +309,19 @@ function getHeadingLevel(heading) {
|
|||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML tag information.
|
||||
*
|
||||
* @typedef {Object} HtmlTagInfo
|
||||
* @property {boolean} close True iff close tag.
|
||||
* @property {string} name Tag name.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets information about the tag in an HTML token.
|
||||
*
|
||||
* @param {Token} token Micromark token.
|
||||
* @returns {Object | null} HTML tag information.
|
||||
* @returns {HtmlTagInfo | null} HTML tag information.
|
||||
*/
|
||||
function getHtmlTagInfo(token) {
|
||||
const htmlTagNameRe = /^<([^!>][^/\s>]*)/;
|
||||
|
|
@ -405,6 +413,21 @@ function tokenIfType(token, type) {
|
|||
return (token && (token.type === type)) ? token : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set containing token types that do not contain content.
|
||||
*
|
||||
* @type {Set<TokenType>}
|
||||
*/
|
||||
const nonContentTokens = new Set([
|
||||
"blockQuoteMarker",
|
||||
"blockQuotePrefix",
|
||||
"blockQuotePrefixWhitespace",
|
||||
"lineEnding",
|
||||
"lineEndingBlank",
|
||||
"linePrefix",
|
||||
"listItemIndent"
|
||||
]);
|
||||
|
||||
module.exports = {
|
||||
"parse": micromarkParse,
|
||||
filterByPredicate,
|
||||
|
|
@ -415,6 +438,8 @@ module.exports = {
|
|||
getTokenParentOfType,
|
||||
getTokenTextByType,
|
||||
inHtmlFlow,
|
||||
isHtmlFlowComment,
|
||||
matchAndGetTokensByType,
|
||||
nonContentTokens,
|
||||
tokenIfType
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue