mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Reimplement MD007/ul-indent using micromark tokens, reduce the length of fix edits (fixes #969).
This commit is contained in:
parent
cdf0818752
commit
da17cec722
11 changed files with 1138 additions and 238 deletions
|
|
@ -23,6 +23,14 @@ const flatTokensSymbol = Symbol("flat-tokens");
|
|||
* @property {number} endColumn End column (1-based).
|
||||
* @property {string} text Token text.
|
||||
* @property {Token[]} children Child tokens.
|
||||
* @property {GetTokenParent} parent Parent token.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns parent Token of a Token.
|
||||
*
|
||||
* @typedef {Function} GetTokenParent
|
||||
* @returns {Token} Parent token.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -113,10 +121,11 @@ function micromarkParseWithOffset(
|
|||
// Create Token objects
|
||||
const document = [];
|
||||
let flatTokens = [];
|
||||
let current = {
|
||||
const root = {
|
||||
"children": document
|
||||
};
|
||||
const history = [ current ];
|
||||
const history = [ root ];
|
||||
let current = root;
|
||||
let reparseOptions = null;
|
||||
let lines = null;
|
||||
let skipHtmlFlowChildren = false;
|
||||
|
|
@ -136,7 +145,8 @@ function micromarkParseWithOffset(
|
|||
"endLine": endLine + lineDelta,
|
||||
endColumn,
|
||||
text,
|
||||
"children": []
|
||||
"children": [],
|
||||
"parent": () => (previous === root ? null : previous)
|
||||
};
|
||||
previous.children.push(current);
|
||||
flatTokens.push(current);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue