@thallylabs/migrate 0.2.35 → 0.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/url-migration.js +20 -4
- package/dist/url-migration.js.map +1 -1
- package/package.json +1 -1
package/dist/url-migration.js
CHANGED
|
@@ -3306,7 +3306,14 @@ ${normalized.slice(1).map((row) => `| ${row.join(" | ")} |`).join("\n")}
|
|
|
3306
3306
|
const fragment = load2(element.outerHTML);
|
|
3307
3307
|
const tokenLines = fragment(".token-line").toArray();
|
|
3308
3308
|
const code = (tokenLines.length > 0 ? tokenLines.map((line) => fragment(line).text()).join("\n") : fragment("pre").text()).replace(/\n$/, "");
|
|
3309
|
-
const language =
|
|
3309
|
+
const language = ["code", "pre"].flatMap((selector) => {
|
|
3310
|
+
const block = fragment(selector).first();
|
|
3311
|
+
return [
|
|
3312
|
+
block.attr("language"),
|
|
3313
|
+
block.attr("data-language"),
|
|
3314
|
+
block.attr("class")?.match(/(?:^|\s)(?:language-|lang-)([A-Za-z0-9_+-]+)(?=\s|$)/)?.[1]
|
|
3315
|
+
];
|
|
3316
|
+
}).find((value) => value !== void 0 && /^[A-Za-z0-9_+-]{1,64}$/.test(value)) ?? "";
|
|
3310
3317
|
const longestFence = Math.max(0, ...[...code.matchAll(/`+/g)].map((match) => match[0].length));
|
|
3311
3318
|
const fence = "`".repeat(Math.max(3, longestFence + 1));
|
|
3312
3319
|
return `
|
|
@@ -3760,7 +3767,7 @@ function validateUrlMigration(checkpoint, cancelled = false) {
|
|
|
3760
3767
|
} catch {
|
|
3761
3768
|
}
|
|
3762
3769
|
if (!destination.evidence?.anchors.includes(anchor)) {
|
|
3763
|
-
warnings.push({ code: "source-link-warning", source: record.url, message: `The original source link refers to an absent source anchor: ${link}` });
|
|
3770
|
+
warnings.push({ code: "source-link-warning", source: record.url, message: `The original source link refers to an absent source anchor; the imported link opens the page instead: ${link}` });
|
|
3764
3771
|
} else if (destination.page) {
|
|
3765
3772
|
const nodes = markdownNodes(destination.page.body);
|
|
3766
3773
|
const explicit = nodes.flatMap((node) => node.name === "a" ? (node.attributes ?? []).flatMap((attribute) => attribute.name === "id" && typeof attribute.value === "string" ? [attribute.value] : []) : []);
|
|
@@ -4209,8 +4216,17 @@ ${difference}`;
|
|
|
4209
4216
|
} catch {
|
|
4210
4217
|
return value;
|
|
4211
4218
|
}
|
|
4212
|
-
const
|
|
4213
|
-
|
|
4219
|
+
const identity = canonical(url.toString(), sourceUrl);
|
|
4220
|
+
const route = routeMap.get(identity);
|
|
4221
|
+
if (!route) return value;
|
|
4222
|
+
const destination = resolveMigrationRecord(records, records.get(identity));
|
|
4223
|
+
let anchor = url.hash.slice(1);
|
|
4224
|
+
try {
|
|
4225
|
+
anchor = decodeURIComponent(anchor);
|
|
4226
|
+
} catch {
|
|
4227
|
+
}
|
|
4228
|
+
const hasBrokenSourceAnchor = Boolean(url.hash && destination?.outcome === "imported" && destination.evidence && !destination.evidence.anchors.includes(anchor));
|
|
4229
|
+
return `${route}${hasBrokenSourceAnchor ? "" : url.hash}`;
|
|
4214
4230
|
}) }] : []);
|
|
4215
4231
|
const validation = validateUrlMigration(checkpoint, Boolean(options.signal?.aborted));
|
|
4216
4232
|
validation.issues.push(...navigationIssues);
|