@thallylabs/migrate 0.2.37 → 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.
@@ -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 = fragment("code").attr("class")?.match(/(?:language-|lang-)([A-Za-z0-9_+-]+)/)?.[1] ?? "";
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 `