mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10: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 isFullOrCollapsed = false;
|
||||||
var labelText = null;
|
var labelText = null;
|
||||||
var referenceStringText = null;
|
var referenceStringText = null;
|
||||||
var shortcutCandidate = micromark.matchAndGetTokensByType(token.tokens, ["label"]);
|
var shortcutCandidate = micromark.matchAndGetTokensByType(token.children, ["label"]);
|
||||||
if (shortcutCandidate) {
|
if (shortcutCandidate) {
|
||||||
labelText = micromark.getTokenTextByType(shortcutCandidate[0].tokens, "labelText");
|
labelText = micromark.getTokenTextByType(shortcutCandidate[0].children, "labelText");
|
||||||
isShortcut = labelText !== null;
|
isShortcut = labelText !== null;
|
||||||
}
|
}
|
||||||
var fullAndCollapsedCandidate = micromark.matchAndGetTokensByType(token.tokens, ["label", "reference"]);
|
var fullAndCollapsedCandidate = micromark.matchAndGetTokensByType(token.children, ["label", "reference"]);
|
||||||
if (fullAndCollapsedCandidate) {
|
if (fullAndCollapsedCandidate) {
|
||||||
labelText = micromark.getTokenTextByType(fullAndCollapsedCandidate[0].tokens, "labelText");
|
labelText = micromark.getTokenTextByType(fullAndCollapsedCandidate[0].children, "labelText");
|
||||||
referenceStringText = micromark.getTokenTextByType(fullAndCollapsedCandidate[1].tokens, "referenceString");
|
referenceStringText = micromark.getTokenTextByType(fullAndCollapsedCandidate[1].children, "referenceString");
|
||||||
isFullOrCollapsed = labelText !== null;
|
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) {
|
if (footnote) {
|
||||||
var callMarkerText = footnote[0].text;
|
var callMarkerText = footnote[0].text;
|
||||||
var callString = footnote[1].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} endLine End line (1-based).
|
||||||
* @property {number} endColumn End column (1-based).
|
* @property {number} endColumn End column (1-based).
|
||||||
* @property {string} text Token text.
|
* @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
|
// Create Token objects
|
||||||
var document = [];
|
var document = [];
|
||||||
var current = {
|
var current = {
|
||||||
"tokens": document
|
"children": document
|
||||||
};
|
};
|
||||||
var history = [current];
|
var history = [current];
|
||||||
var _iterator = _createForOfIteratorHelper(events),
|
var _iterator = _createForOfIteratorHelper(events),
|
||||||
|
|
@ -1534,11 +1534,11 @@ function micromarkParse(markdown) {
|
||||||
endLine: endLine,
|
endLine: endLine,
|
||||||
endColumn: endColumn,
|
endColumn: endColumn,
|
||||||
text: text,
|
text: text,
|
||||||
"tokens": []
|
"children": []
|
||||||
};
|
};
|
||||||
previous.tokens.push(current);
|
previous.children.push(current);
|
||||||
} else if (kind === "exit") {
|
} else if (kind === "exit") {
|
||||||
Object.freeze(current.tokens);
|
Object.freeze(current.children);
|
||||||
Object.freeze(current);
|
Object.freeze(current);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
current = history.pop();
|
current = history.pop();
|
||||||
|
|
@ -1571,7 +1571,7 @@ function filterByPredicate(tokens, allowed, transform) {
|
||||||
if (allowed(token)) {
|
if (allowed(token)) {
|
||||||
result.push(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));
|
pending.unshift.apply(pending, _toConsumableArray(transformed));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -5441,13 +5441,13 @@ module.exports = {
|
||||||
try {
|
try {
|
||||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||||
var token = _step.value;
|
var token = _step.value;
|
||||||
var tokens = token.tokens;
|
var children = token.children;
|
||||||
var first = 0;
|
var first = 0;
|
||||||
var last = tokens.length - 1;
|
var last = children.length - 1;
|
||||||
var startSequence = tokenIfType(tokens[first], "codeTextSequence");
|
var startSequence = tokenIfType(children[first], "codeTextSequence");
|
||||||
var endSequence = tokenIfType(tokens[last], "codeTextSequence");
|
var endSequence = tokenIfType(children[last], "codeTextSequence");
|
||||||
var startData = tokenIfType(tokens[first + 1], "codeTextData") || tokenIfType(tokens[first + 2], "codeTextData");
|
var startData = tokenIfType(children[first + 1], "codeTextData") || tokenIfType(children[first + 2], "codeTextData");
|
||||||
var endData = tokenIfType(tokens[last - 1], "codeTextData") || tokenIfType(tokens[last - 2], "codeTextData");
|
var endData = tokenIfType(children[last - 1], "codeTextData") || tokenIfType(children[last - 2], "codeTextData");
|
||||||
if (startSequence && endSequence && startData && endData) {
|
if (startSequence && endSequence && startData && endData) {
|
||||||
var spaceLeft = leftSpaceRe.test(startData.text);
|
var spaceLeft = leftSpaceRe.test(startData.text);
|
||||||
var spaceRight = !spaceLeft && rightSpaceRe.test(endData.text);
|
var spaceRight = !spaceLeft && rightSpaceRe.test(endData.text);
|
||||||
|
|
|
||||||
|
|
@ -858,31 +858,31 @@ function getReferenceLinkImageData(params) {
|
||||||
let labelText = null;
|
let labelText = null;
|
||||||
let referenceStringText = null;
|
let referenceStringText = null;
|
||||||
const shortcutCandidate =
|
const shortcutCandidate =
|
||||||
micromark.matchAndGetTokensByType(token.tokens, [ "label" ]);
|
micromark.matchAndGetTokensByType(token.children, [ "label" ]);
|
||||||
if (shortcutCandidate) {
|
if (shortcutCandidate) {
|
||||||
labelText =
|
labelText =
|
||||||
micromark.getTokenTextByType(
|
micromark.getTokenTextByType(
|
||||||
shortcutCandidate[0].tokens, "labelText"
|
shortcutCandidate[0].children, "labelText"
|
||||||
);
|
);
|
||||||
isShortcut = (labelText !== null);
|
isShortcut = (labelText !== null);
|
||||||
}
|
}
|
||||||
const fullAndCollapsedCandidate =
|
const fullAndCollapsedCandidate =
|
||||||
micromark.matchAndGetTokensByType(
|
micromark.matchAndGetTokensByType(
|
||||||
token.tokens, [ "label", "reference" ]
|
token.children, [ "label", "reference" ]
|
||||||
);
|
);
|
||||||
if (fullAndCollapsedCandidate) {
|
if (fullAndCollapsedCandidate) {
|
||||||
labelText =
|
labelText =
|
||||||
micromark.getTokenTextByType(
|
micromark.getTokenTextByType(
|
||||||
fullAndCollapsedCandidate[0].tokens, "labelText"
|
fullAndCollapsedCandidate[0].children, "labelText"
|
||||||
);
|
);
|
||||||
referenceStringText =
|
referenceStringText =
|
||||||
micromark.getTokenTextByType(
|
micromark.getTokenTextByType(
|
||||||
fullAndCollapsedCandidate[1].tokens, "referenceString"
|
fullAndCollapsedCandidate[1].children, "referenceString"
|
||||||
);
|
);
|
||||||
isFullOrCollapsed = (labelText !== null);
|
isFullOrCollapsed = (labelText !== null);
|
||||||
}
|
}
|
||||||
const footnote = micromark.matchAndGetTokensByType(
|
const footnote = micromark.matchAndGetTokensByType(
|
||||||
token.tokens,
|
token.children,
|
||||||
[
|
[
|
||||||
"gfmFootnoteCallLabelMarker", "gfmFootnoteCallMarker",
|
"gfmFootnoteCallLabelMarker", "gfmFootnoteCallMarker",
|
||||||
"gfmFootnoteCallString", "gfmFootnoteCallLabelMarker"
|
"gfmFootnoteCallString", "gfmFootnoteCallLabelMarker"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const {
|
||||||
* @property {number} endLine End line (1-based).
|
* @property {number} endLine End line (1-based).
|
||||||
* @property {number} endColumn End column (1-based).
|
* @property {number} endColumn End column (1-based).
|
||||||
* @property {string} text Token text.
|
* @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
|
// Create Token objects
|
||||||
const document = [];
|
const document = [];
|
||||||
let current = {
|
let current = {
|
||||||
"tokens": document
|
"children": document
|
||||||
};
|
};
|
||||||
const history = [ current ];
|
const history = [ current ];
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
|
|
@ -84,11 +84,11 @@ function micromarkParse(markdown, options = {}) {
|
||||||
endLine,
|
endLine,
|
||||||
endColumn,
|
endColumn,
|
||||||
text,
|
text,
|
||||||
"tokens": []
|
"children": []
|
||||||
};
|
};
|
||||||
previous.tokens.push(current);
|
previous.children.push(current);
|
||||||
} else if (kind === "exit") {
|
} else if (kind === "exit") {
|
||||||
Object.freeze(current.tokens);
|
Object.freeze(current.children);
|
||||||
Object.freeze(current);
|
Object.freeze(current);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
current = history.pop();
|
current = history.pop();
|
||||||
|
|
@ -116,7 +116,7 @@ function filterByPredicate(tokens, allowed, transform) {
|
||||||
if (allowed(token)) {
|
if (allowed(token)) {
|
||||||
result.push(token);
|
result.push(token);
|
||||||
}
|
}
|
||||||
const transformed = transform ? transform(token.tokens) : token.tokens;
|
const transformed = transform ? transform(token.children) : token.children;
|
||||||
pending.unshift(...transformed);
|
pending.unshift(...transformed);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
16
lib/md038.js
16
lib/md038.js
|
|
@ -27,17 +27,17 @@ module.exports = {
|
||||||
const codeTextTokens =
|
const codeTextTokens =
|
||||||
filterByTypes(params.parsers.micromark.tokens, [ "codeText" ]);
|
filterByTypes(params.parsers.micromark.tokens, [ "codeText" ]);
|
||||||
for (const token of codeTextTokens) {
|
for (const token of codeTextTokens) {
|
||||||
const { tokens } = token;
|
const { children } = token;
|
||||||
const first = 0;
|
const first = 0;
|
||||||
const last = tokens.length - 1;
|
const last = children.length - 1;
|
||||||
const startSequence = tokenIfType(tokens[first], "codeTextSequence");
|
const startSequence = tokenIfType(children[first], "codeTextSequence");
|
||||||
const endSequence = tokenIfType(tokens[last], "codeTextSequence");
|
const endSequence = tokenIfType(children[last], "codeTextSequence");
|
||||||
const startData =
|
const startData =
|
||||||
tokenIfType(tokens[first + 1], "codeTextData") ||
|
tokenIfType(children[first + 1], "codeTextData") ||
|
||||||
tokenIfType(tokens[first + 2], "codeTextData");
|
tokenIfType(children[first + 2], "codeTextData");
|
||||||
const endData =
|
const endData =
|
||||||
tokenIfType(tokens[last - 1], "codeTextData") ||
|
tokenIfType(children[last - 1], "codeTextData") ||
|
||||||
tokenIfType(tokens[last - 2], "codeTextData");
|
tokenIfType(children[last - 2], "codeTextData");
|
||||||
if (startSequence && endSequence && startData && endData) {
|
if (startSequence && endSequence && startData && endData) {
|
||||||
const spaceLeft = leftSpaceRe.test(startData.text);
|
const spaceLeft = leftSpaceRe.test(startData.text);
|
||||||
const spaceRight = !spaceLeft && rightSpaceRe.test(endData.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