mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Reimplement MD044/proper-names using micromark tokens.
This commit is contained in:
parent
e8a85c91f2
commit
5bff33d41b
9 changed files with 182 additions and 495 deletions
|
@ -105,10 +105,10 @@ function micromarkParse(markdown, options = {}) {
|
|||
*
|
||||
* @param {Token[]} tokens Micromark tokens.
|
||||
* @param {Function} allowed Allowed token predicate.
|
||||
* @param {Function} [transform] Transform token list predicate.
|
||||
* @param {Function} [transformChildren] Transform children predicate.
|
||||
* @returns {Token[]} Filtered tokens.
|
||||
*/
|
||||
function filterByPredicate(tokens, allowed, transform) {
|
||||
function filterByPredicate(tokens, allowed, transformChildren) {
|
||||
const result = [];
|
||||
const pending = [ ...tokens ];
|
||||
let token = null;
|
||||
|
@ -118,7 +118,7 @@ function filterByPredicate(tokens, allowed, transform) {
|
|||
}
|
||||
if (token.children.length > 0) {
|
||||
const transformed =
|
||||
transform ? transform(token.children) : token.children;
|
||||
transformChildren ? transformChildren(token) : token.children;
|
||||
pending.unshift(...transformed);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue