mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-19 15:30:13 +01:00
Change helpers.getReferenceLinkImageData().shortcuts from Set to Map using the same schema as .references (fixes #685).
This commit is contained in:
parent
f000a33481
commit
86a4a7de79
2 changed files with 24 additions and 18 deletions
|
|
@ -792,7 +792,7 @@ module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
|
||||||
function getReferenceLinkImageData(lineMetadata) {
|
function getReferenceLinkImageData(lineMetadata) {
|
||||||
// Initialize return values
|
// Initialize return values
|
||||||
const references = new Map();
|
const references = new Map();
|
||||||
const shortcuts = new Set();
|
const shortcuts = new Map();
|
||||||
const definitions = new Map();
|
const definitions = new Map();
|
||||||
const duplicateDefinitions = [];
|
const duplicateDefinitions = [];
|
||||||
const definitionLineIndices = [];
|
const definitionLineIndices = [];
|
||||||
|
|
@ -882,20 +882,23 @@ function getReferenceLinkImageData(lineMetadata) {
|
||||||
}
|
}
|
||||||
const referenceIndex = referenceindex +
|
const referenceIndex = referenceindex +
|
||||||
(topLevel ? -lineOffsets[lineIndex] : contentIndex);
|
(topLevel ? -lineOffsets[lineIndex] : contentIndex);
|
||||||
|
const referenceDatum = [
|
||||||
|
lineIndex,
|
||||||
|
referenceIndex,
|
||||||
|
matchString.length,
|
||||||
|
matchText.length,
|
||||||
|
(matchLabel || "").length
|
||||||
|
];
|
||||||
if (shortcutLink) {
|
if (shortcutLink) {
|
||||||
// Track separately due to ambiguity in "text [text] text"
|
// Track separately due to ambiguity in "text [text] text"
|
||||||
shortcuts.add(label);
|
const shortcutData = shortcuts.get(label) || [];
|
||||||
|
shortcutData.push(referenceDatum);
|
||||||
|
shortcuts.set(label, shortcutData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Track reference and location
|
// Track reference and location
|
||||||
const referenceData = references.get(label) || [];
|
const referenceData = references.get(label) || [];
|
||||||
referenceData.push([
|
referenceData.push(referenceDatum);
|
||||||
lineIndex,
|
|
||||||
referenceIndex,
|
|
||||||
matchString.length,
|
|
||||||
matchText.length,
|
|
||||||
matchLabel.length
|
|
||||||
]);
|
|
||||||
references.set(label, referenceData);
|
references.set(label, referenceData);
|
||||||
}
|
}
|
||||||
// Check for links embedded in brackets
|
// Check for links embedded in brackets
|
||||||
|
|
|
||||||
|
|
@ -824,7 +824,7 @@ module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
|
||||||
function getReferenceLinkImageData(lineMetadata) {
|
function getReferenceLinkImageData(lineMetadata) {
|
||||||
// Initialize return values
|
// Initialize return values
|
||||||
const references = new Map();
|
const references = new Map();
|
||||||
const shortcuts = new Set();
|
const shortcuts = new Map();
|
||||||
const definitions = new Map();
|
const definitions = new Map();
|
||||||
const duplicateDefinitions = [];
|
const duplicateDefinitions = [];
|
||||||
const definitionLineIndices = [];
|
const definitionLineIndices = [];
|
||||||
|
|
@ -920,19 +920,22 @@ function getReferenceLinkImageData(lineMetadata) {
|
||||||
}
|
}
|
||||||
const referenceIndex = referenceindex +
|
const referenceIndex = referenceindex +
|
||||||
(topLevel ? -lineOffsets[lineIndex] : contentIndex);
|
(topLevel ? -lineOffsets[lineIndex] : contentIndex);
|
||||||
|
const referenceDatum = [
|
||||||
|
lineIndex,
|
||||||
|
referenceIndex,
|
||||||
|
matchString.length,
|
||||||
|
matchText.length,
|
||||||
|
(matchLabel || "").length
|
||||||
|
];
|
||||||
if (shortcutLink) {
|
if (shortcutLink) {
|
||||||
// Track separately due to ambiguity in "text [text] text"
|
// Track separately due to ambiguity in "text [text] text"
|
||||||
shortcuts.add(label);
|
const shortcutData = shortcuts.get(label) || [];
|
||||||
|
shortcutData.push(referenceDatum);
|
||||||
|
shortcuts.set(label, shortcutData);
|
||||||
} else {
|
} else {
|
||||||
// Track reference and location
|
// Track reference and location
|
||||||
const referenceData = references.get(label) || [];
|
const referenceData = references.get(label) || [];
|
||||||
referenceData.push([
|
referenceData.push(referenceDatum);
|
||||||
lineIndex,
|
|
||||||
referenceIndex,
|
|
||||||
matchString.length,
|
|
||||||
matchText.length,
|
|
||||||
matchLabel.length
|
|
||||||
]);
|
|
||||||
references.set(label, referenceData);
|
references.set(label, referenceData);
|
||||||
}
|
}
|
||||||
// Check for links embedded in brackets
|
// Check for links embedded in brackets
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue