mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Rename markdownlint-micromark Token's .tokens property to .children for consistency and clarity.
This commit is contained in:
parent
781b854f4b
commit
13ced64c21
6 changed files with 1558 additions and 1558 deletions
|
|
@ -950,18 +950,18 @@ function getReferenceLinkImageData(params) {
|
|||
var isFullOrCollapsed = false;
|
||||
var labelText = null;
|
||||
var referenceStringText = null;
|
||||
var shortcutCandidate = micromark.matchAndGetTokensByType(token.tokens, ["label"]);
|
||||
var shortcutCandidate = micromark.matchAndGetTokensByType(token.children, ["label"]);
|
||||
if (shortcutCandidate) {
|
||||
labelText = micromark.getTokenTextByType(shortcutCandidate[0].tokens, "labelText");
|
||||
labelText = micromark.getTokenTextByType(shortcutCandidate[0].children, "labelText");
|
||||
isShortcut = labelText !== null;
|
||||
}
|
||||
var fullAndCollapsedCandidate = micromark.matchAndGetTokensByType(token.tokens, ["label", "reference"]);
|
||||
var fullAndCollapsedCandidate = micromark.matchAndGetTokensByType(token.children, ["label", "reference"]);
|
||||
if (fullAndCollapsedCandidate) {
|
||||
labelText = micromark.getTokenTextByType(fullAndCollapsedCandidate[0].tokens, "labelText");
|
||||
referenceStringText = micromark.getTokenTextByType(fullAndCollapsedCandidate[1].tokens, "referenceString");
|
||||
labelText = micromark.getTokenTextByType(fullAndCollapsedCandidate[0].children, "labelText");
|
||||
referenceStringText = micromark.getTokenTextByType(fullAndCollapsedCandidate[1].children, "referenceString");
|
||||
isFullOrCollapsed = labelText !== null;
|
||||
}
|
||||
var footnote = micromark.matchAndGetTokensByType(token.tokens, ["gfmFootnoteCallLabelMarker", "gfmFootnoteCallMarker", "gfmFootnoteCallString", "gfmFootnoteCallLabelMarker"], ["gfmFootnoteCallMarker", "gfmFootnoteCallString"]);
|
||||
var footnote = micromark.matchAndGetTokensByType(token.children, ["gfmFootnoteCallLabelMarker", "gfmFootnoteCallMarker", "gfmFootnoteCallString", "gfmFootnoteCallLabelMarker"], ["gfmFootnoteCallMarker", "gfmFootnoteCallString"]);
|
||||
if (footnote) {
|
||||
var callMarkerText = footnote[0].text;
|
||||
var callString = footnote[1].text;
|
||||
|
|
@ -1455,7 +1455,7 @@ var _require = __webpack_require__(/*! markdownlint-micromark */ "markdownlint-m
|
|||
* @property {number} endLine End line (1-based).
|
||||
* @property {number} endColumn End column (1-based).
|
||||
* @property {string} text Token text.
|
||||
* @property {Token[]} tokens Child tokens.
|
||||
* @property {Token[]} children Child tokens.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -1499,7 +1499,7 @@ function micromarkParse(markdown) {
|
|||
// Create Token objects
|
||||
var document = [];
|
||||
var current = {
|
||||
"tokens": document
|
||||
"children": document
|
||||
};
|
||||
var history = [current];
|
||||
var _iterator = _createForOfIteratorHelper(events),
|
||||
|
|
@ -1534,11 +1534,11 @@ function micromarkParse(markdown) {
|
|||
endLine: endLine,
|
||||
endColumn: endColumn,
|
||||
text: text,
|
||||
"tokens": []
|
||||
"children": []
|
||||
};
|
||||
previous.tokens.push(current);
|
||||
previous.children.push(current);
|
||||
} else if (kind === "exit") {
|
||||
Object.freeze(current.tokens);
|
||||
Object.freeze(current.children);
|
||||
Object.freeze(current);
|
||||
// @ts-ignore
|
||||
current = history.pop();
|
||||
|
|
@ -1571,7 +1571,7 @@ function filterByPredicate(tokens, allowed, transform) {
|
|||
if (allowed(token)) {
|
||||
result.push(token);
|
||||
}
|
||||
var transformed = transform ? transform(token.tokens) : token.tokens;
|
||||
var transformed = transform ? transform(token.children) : token.children;
|
||||
pending.unshift.apply(pending, _toConsumableArray(transformed));
|
||||
}
|
||||
return result;
|
||||
|
|
@ -5441,13 +5441,13 @@ module.exports = {
|
|||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
var token = _step.value;
|
||||
var tokens = token.tokens;
|
||||
var children = token.children;
|
||||
var first = 0;
|
||||
var last = tokens.length - 1;
|
||||
var startSequence = tokenIfType(tokens[first], "codeTextSequence");
|
||||
var endSequence = tokenIfType(tokens[last], "codeTextSequence");
|
||||
var startData = tokenIfType(tokens[first + 1], "codeTextData") || tokenIfType(tokens[first + 2], "codeTextData");
|
||||
var endData = tokenIfType(tokens[last - 1], "codeTextData") || tokenIfType(tokens[last - 2], "codeTextData");
|
||||
var last = children.length - 1;
|
||||
var startSequence = tokenIfType(children[first], "codeTextSequence");
|
||||
var endSequence = tokenIfType(children[last], "codeTextSequence");
|
||||
var startData = tokenIfType(children[first + 1], "codeTextData") || tokenIfType(children[first + 2], "codeTextData");
|
||||
var endData = tokenIfType(children[last - 1], "codeTextData") || tokenIfType(children[last - 2], "codeTextData");
|
||||
if (startSequence && endSequence && startData && endData) {
|
||||
var spaceLeft = leftSpaceRe.test(startData.text);
|
||||
var spaceRight = !spaceLeft && rightSpaceRe.test(endData.text);
|
||||
|
|
|
|||
|
|
@ -858,31 +858,31 @@ function getReferenceLinkImageData(params) {
|
|||
let labelText = null;
|
||||
let referenceStringText = null;
|
||||
const shortcutCandidate =
|
||||
micromark.matchAndGetTokensByType(token.tokens, [ "label" ]);
|
||||
micromark.matchAndGetTokensByType(token.children, [ "label" ]);
|
||||
if (shortcutCandidate) {
|
||||
labelText =
|
||||
micromark.getTokenTextByType(
|
||||
shortcutCandidate[0].tokens, "labelText"
|
||||
shortcutCandidate[0].children, "labelText"
|
||||
);
|
||||
isShortcut = (labelText !== null);
|
||||
}
|
||||
const fullAndCollapsedCandidate =
|
||||
micromark.matchAndGetTokensByType(
|
||||
token.tokens, [ "label", "reference" ]
|
||||
token.children, [ "label", "reference" ]
|
||||
);
|
||||
if (fullAndCollapsedCandidate) {
|
||||
labelText =
|
||||
micromark.getTokenTextByType(
|
||||
fullAndCollapsedCandidate[0].tokens, "labelText"
|
||||
fullAndCollapsedCandidate[0].children, "labelText"
|
||||
);
|
||||
referenceStringText =
|
||||
micromark.getTokenTextByType(
|
||||
fullAndCollapsedCandidate[1].tokens, "referenceString"
|
||||
fullAndCollapsedCandidate[1].children, "referenceString"
|
||||
);
|
||||
isFullOrCollapsed = (labelText !== null);
|
||||
}
|
||||
const footnote = micromark.matchAndGetTokensByType(
|
||||
token.tokens,
|
||||
token.children,
|
||||
[
|
||||
"gfmFootnoteCallLabelMarker", "gfmFootnoteCallMarker",
|
||||
"gfmFootnoteCallString", "gfmFootnoteCallLabelMarker"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const {
|
|||
* @property {number} endLine End line (1-based).
|
||||
* @property {number} endColumn End column (1-based).
|
||||
* @property {string} text Token text.
|
||||
* @property {Token[]} tokens Child tokens.
|
||||
* @property {Token[]} children Child tokens.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -60,7 +60,7 @@ function micromarkParse(markdown, options = {}) {
|
|||
// Create Token objects
|
||||
const document = [];
|
||||
let current = {
|
||||
"tokens": document
|
||||
"children": document
|
||||
};
|
||||
const history = [ current ];
|
||||
for (const event of events) {
|
||||
|
|
@ -84,11 +84,11 @@ function micromarkParse(markdown, options = {}) {
|
|||
endLine,
|
||||
endColumn,
|
||||
text,
|
||||
"tokens": []
|
||||
"children": []
|
||||
};
|
||||
previous.tokens.push(current);
|
||||
previous.children.push(current);
|
||||
} else if (kind === "exit") {
|
||||
Object.freeze(current.tokens);
|
||||
Object.freeze(current.children);
|
||||
Object.freeze(current);
|
||||
// @ts-ignore
|
||||
current = history.pop();
|
||||
|
|
@ -116,7 +116,7 @@ function filterByPredicate(tokens, allowed, transform) {
|
|||
if (allowed(token)) {
|
||||
result.push(token);
|
||||
}
|
||||
const transformed = transform ? transform(token.tokens) : token.tokens;
|
||||
const transformed = transform ? transform(token.children) : token.children;
|
||||
pending.unshift(...transformed);
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
16
lib/md038.js
16
lib/md038.js
|
|
@ -27,17 +27,17 @@ module.exports = {
|
|||
const codeTextTokens =
|
||||
filterByTypes(params.parsers.micromark.tokens, [ "codeText" ]);
|
||||
for (const token of codeTextTokens) {
|
||||
const { tokens } = token;
|
||||
const { children } = token;
|
||||
const first = 0;
|
||||
const last = tokens.length - 1;
|
||||
const startSequence = tokenIfType(tokens[first], "codeTextSequence");
|
||||
const endSequence = tokenIfType(tokens[last], "codeTextSequence");
|
||||
const last = children.length - 1;
|
||||
const startSequence = tokenIfType(children[first], "codeTextSequence");
|
||||
const endSequence = tokenIfType(children[last], "codeTextSequence");
|
||||
const startData =
|
||||
tokenIfType(tokens[first + 1], "codeTextData") ||
|
||||
tokenIfType(tokens[first + 2], "codeTextData");
|
||||
tokenIfType(children[first + 1], "codeTextData") ||
|
||||
tokenIfType(children[first + 2], "codeTextData");
|
||||
const endData =
|
||||
tokenIfType(tokens[last - 1], "codeTextData") ||
|
||||
tokenIfType(tokens[last - 2], "codeTextData");
|
||||
tokenIfType(children[last - 1], "codeTextData") ||
|
||||
tokenIfType(children[last - 2], "codeTextData");
|
||||
if (startSequence && endSequence && startData && endData) {
|
||||
const spaceLeft = leftSpaceRe.test(startData.text);
|
||||
const spaceRight = !spaceLeft && rightSpaceRe.test(endData.text);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue