vuepress-plugin-md-power 1.0.0-rc.164 → 1.0.0-rc.166

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/lib/node/index.js CHANGED
@@ -1007,10 +1007,7 @@ async function imageSizePlugin(app, md, type = false) {
1007
1007
  md.renderer.rules.image = (tokens, idx, options, env, self) => {
1008
1008
  if (!env.filePathRelative || !env.filePath) return imageRule(tokens, idx, options, env, self);
1009
1009
  const token = tokens[idx];
1010
- const src = token.attrGet("src");
1011
- const width = token.attrGet("width");
1012
- const height = token.attrGet("height");
1013
- const size = resolveSize(src, width, height, env);
1010
+ const size = resolveSize(token.attrGet("src"), token.attrGet("width"), token.attrGet("height"), env);
1014
1011
  if (size) {
1015
1012
  token.attrSet("width", `${size.width}`);
1016
1013
  token.attrSet("height", `${size.height}`);
@@ -1026,8 +1023,7 @@ async function imageSizePlugin(app, md, type = false) {
1026
1023
  const token = tokens[idx];
1027
1024
  token.content = token.content.replace(REG_IMG_TAG, (raw, info) => {
1028
1025
  const { attrs: attrs$1 } = resolveAttrs(info);
1029
- const src = attrs$1.src || attrs$1.srcset;
1030
- const size = resolveSize(src, attrs$1.width, attrs$1.height, env);
1026
+ const size = resolveSize(attrs$1.src || attrs$1.srcset, attrs$1.width, attrs$1.height, env);
1031
1027
  if (!size) return raw;
1032
1028
  attrs$1.width = size.width;
1033
1029
  attrs$1.height = size.height;
@@ -1092,15 +1088,9 @@ async function scanRemoteImageSize(app) {
1092
1088
  if ((await fs.stat(filepath$1)).isFile() && !filepath$1.includes(".vuepress") && !filepath$1.includes("node_modules") && filepath$1.endsWith(".md")) {
1093
1089
  const content = await fs.readFile(filepath$1, "utf-8");
1094
1090
  const syntaxMatched = content.match(REG_IMG) ?? [];
1095
- for (const img of syntaxMatched) {
1096
- const src = img.slice(img.indexOf("](") + 2, -1);
1097
- addList(src.split(/\s+/)[0]);
1098
- }
1091
+ for (const img of syntaxMatched) addList(img.slice(img.indexOf("](") + 2, -1).split(/\s+/)[0]);
1099
1092
  const tagMatched = content.match(REG_IMG_TAG) ?? [];
1100
- for (const img of tagMatched) {
1101
- const src = img.match(REG_IMG_TAG_SRC)?.[2] ?? "";
1102
- addList(src);
1103
- }
1093
+ for (const img of tagMatched) addList(img.match(REG_IMG_TAG_SRC)?.[2] ?? "");
1104
1094
  }
1105
1095
  }
1106
1096
  function addList(src) {
@@ -2516,11 +2506,10 @@ const tabs = (md) => {
2516
2506
  openRender: ({ active, data }, tokens, index, _, env) => {
2517
2507
  const { meta } = tokens[index];
2518
2508
  const titles = data.map(({ title }) => md.renderInline(title, cleanMarkdownEnv(env)));
2519
- const tabsData = data.map((item, dataIndex) => {
2509
+ return `<Tabs id="${index}" :data='${stringifyProp(data.map((item, dataIndex) => {
2520
2510
  const { id = titles[dataIndex] } = item;
2521
2511
  return { id };
2522
- });
2523
- return `<Tabs id="${index}" :data='${stringifyProp(tabsData)}'${active === -1 ? "" : ` :active="${active}"`}${meta.id ? ` tab-id="${meta.id}"` : ""}>
2512
+ }))}'${active === -1 ? "" : ` :active="${active}"`}${meta.id ? ` tab-id="${meta.id}"` : ""}>
2524
2513
  ${titles.map((title, titleIndex) => `<template #title${titleIndex}="{ value, isActive }">${title}</template>`).join("")}`;
2525
2514
  },
2526
2515
  closeRender: () => `</Tabs>`,
@@ -2812,8 +2801,7 @@ function demoWatcher(app, watchers) {
2812
2801
  if (tasks[path$3]) {
2813
2802
  const code$1 = readFileSync(path$3);
2814
2803
  if (code$1 === false) return;
2815
- const source = parseEmbedCode(code$1);
2816
- compileCode(source, tasks[path$3]);
2804
+ compileCode(parseEmbedCode(code$1), tasks[path$3]);
2817
2805
  }
2818
2806
  });
2819
2807
  watcher.on("unlink", (path$3) => {
@@ -2966,8 +2954,7 @@ const normalContainerRender = {
2966
2954
  env.demoFiles.push(demo);
2967
2955
  insertSetupScript(demo, env);
2968
2956
  }
2969
- const source = parseContainerCode(codeMap);
2970
- compileCode(source, output);
2957
+ compileCode(parseContainerCode(codeMap), output);
2971
2958
  return `<VPDemoNormal${stringifyAttrs({
2972
2959
  ":config": name,
2973
2960
  title,
@@ -3528,9 +3515,8 @@ const acfunPlugin = (md) => {
3528
3515
  },
3529
3516
  content(meta) {
3530
3517
  const { id, width, height, ratio, title } = meta;
3531
- const src = `${AC_FUN_LINK}/${id}`;
3532
3518
  return `<VPVideoEmbed${stringifyAttrs({
3533
- src,
3519
+ src: `${AC_FUN_LINK}/${id}`,
3534
3520
  width,
3535
3521
  height,
3536
3522
  ratio,
@@ -3936,8 +3922,7 @@ function resolveIcon(content, options) {
3936
3922
  //#endregion
3937
3923
  //#region src/node/icon/icon.ts
3938
3924
  function iconRender(content, options) {
3939
- const icon = resolveIcon(content, options);
3940
- return `<VPIcon${stringifyAttrs(icon)} />`;
3925
+ return `<VPIcon${stringifyAttrs(resolveIcon(content, options))} />`;
3941
3926
  }
3942
3927
  const iconPlugin = (md, options = {}) => {
3943
3928
  /**
@@ -4032,10 +4017,7 @@ function normalizeLink(link) {
4032
4017
  //#region src/node/inline/abbr.ts
4033
4018
  const abbrPlugin = (md) => {
4034
4019
  const { arrayReplaceAt, escapeRE, lib } = md.utils;
4035
- const OTHER_CHARS = " \r\n$+<=>^`|~";
4036
- const UNICODE_PUNCTUATION_REGEXP = lib.ucmicro.P.source;
4037
- const UNICODE_SPACE_REGEXP = lib.ucmicro.Z.source;
4038
- const WORDING_REGEXP_TEXT = `${UNICODE_PUNCTUATION_REGEXP}|${UNICODE_SPACE_REGEXP}|[${OTHER_CHARS.split("").map(escapeRE).join("")}]`;
4020
+ const WORDING_REGEXP_TEXT = `${lib.ucmicro.P.source}|${lib.ucmicro.Z.source}|[${" \r\n$+<=>^`|~".split("").map(escapeRE).join("")}]`;
4039
4021
  const abbrDefinition = (state, startLine, _endLine, silent) => {
4040
4022
  let labelEnd = -1;
4041
4023
  let pos = state.bMarks[startLine] + state.tShift[startLine];
@@ -4174,8 +4156,7 @@ const annotationPlugin = (md) => {
4174
4156
  const label = tokens[idx].meta.label;
4175
4157
  const data = env.annotations[`:${label}`];
4176
4158
  return `<Annotation label="${label}" :total="${data.sources.length}">${data.sources.map((source, i) => {
4177
- const annotation = data.rendered[i] ??= md.render(source, cleanMarkdownEnv(env, ["references"]));
4178
- return `<template #item-${i}>${annotation}</template>`;
4159
+ return `<template #item-${i}>${data.rendered[i] ??= md.render(source, cleanMarkdownEnv(env, ["references"]))}</template>`;
4179
4160
  }).join("")}</Annotation>`;
4180
4161
  };
4181
4162
  md.inline.ruler.before("image", "annotation_ref", annotationRef);