mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-28 19:48:49 +01:00
Refactor micromark helper getTokenTextByType to be more efficient, remove tokenIfType helper for being redundant.
This commit is contained in:
parent
b749d9fbb4
commit
2ea3f95fd1
6 changed files with 82 additions and 120 deletions
|
|
@ -3,7 +3,7 @@
|
|||
"use strict";
|
||||
|
||||
const { addError, emphasisOrStrongStyleFor } = require("../helpers");
|
||||
const { filterByPredicate, tokenIfType } = require("../helpers/micromark.cjs");
|
||||
const { filterByPredicate, getDescendantsByType } = require("../helpers/micromark.cjs");
|
||||
|
||||
const intrawordRe = /^\w$/;
|
||||
|
||||
|
|
@ -25,9 +25,9 @@ const impl =
|
|||
(token) => ((token.type === "htmlFlow") ? [] : token.children)
|
||||
);
|
||||
for (const token of emphasisTokens) {
|
||||
const { children } = token;
|
||||
const startSequence = tokenIfType(children[0], typeSequence);
|
||||
const endSequence = tokenIfType(children[children.length - 1], typeSequence);
|
||||
const sequences = getDescendantsByType(token, [ typeSequence ]);
|
||||
const startSequence = sequences[0];
|
||||
const endSequence = sequences[sequences.length - 1];
|
||||
if (startSequence && endSequence) {
|
||||
const markupStyle = emphasisOrStrongStyleFor(startSequence.text);
|
||||
if (style === "consistent") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue