mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Refactor micromark token handling to remove optional Token.htmlFlowChildren property and make related code more efficient for a ~6% elapsed time reduction.
This commit is contained in:
parent
e282874fe3
commit
24c97a54fb
16 changed files with 274 additions and 283 deletions
|
@ -3,15 +3,18 @@
|
|||
"use strict";
|
||||
|
||||
const { addError, emphasisOrStrongStyleFor } = require("../helpers");
|
||||
const { filterByTypes, tokenIfType } = require("../helpers/micromark.cjs");
|
||||
const { filterByPredicate, tokenIfType } = require("../helpers/micromark.cjs");
|
||||
|
||||
const intrawordRe = /\w/;
|
||||
|
||||
const impl =
|
||||
(params, onError, type, asterisk, underline, style = "consistent") => {
|
||||
const { lines, parsers } = params;
|
||||
const emphasisTokens =
|
||||
filterByTypes(parsers.micromark.tokens, [ type ]);
|
||||
const emphasisTokens = filterByPredicate(
|
||||
parsers.micromark.tokens,
|
||||
(token) => token.type === type,
|
||||
(token) => ((token.type === "htmlFlow") ? [] : token.children)
|
||||
);
|
||||
for (const token of emphasisTokens) {
|
||||
const { children } = token;
|
||||
const childType = `${type}Sequence`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue