vuepress-plugin-md-power 1.0.0-rc.107 → 1.0.0-rc.108
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.d.ts +1 -1
- package/lib/node/index.js +64 -62
- package/lib/shared/index.d.ts +1 -1
- package/package.json +4 -4
package/lib/node/index.d.ts
CHANGED
package/lib/node/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function resolveAttrs(info) {
|
|
|
16
16
|
const rawAttrs = info;
|
|
17
17
|
let matched;
|
|
18
18
|
while (matched = info.match(RE_ATTR_VALUE)) {
|
|
19
|
-
const { attr, value } = matched.groups
|
|
19
|
+
const { attr, value } = matched.groups;
|
|
20
20
|
attrs2[attr] = value ?? true;
|
|
21
21
|
info = info.slice(matched[0].length);
|
|
22
22
|
}
|
|
@@ -1051,10 +1051,10 @@ var definitions = {
|
|
|
1051
1051
|
};
|
|
1052
1052
|
|
|
1053
1053
|
// src/node/fileIcons/findIcon.ts
|
|
1054
|
-
function getFileIcon(fileName, type2
|
|
1054
|
+
function getFileIcon(fileName, type2) {
|
|
1055
1055
|
const name = getFileIconName(fileName, type2);
|
|
1056
1056
|
if (!name)
|
|
1057
|
-
return type2
|
|
1057
|
+
return type2 !== "folder" ? defaultFile : defaultFolder;
|
|
1058
1058
|
return name;
|
|
1059
1059
|
}
|
|
1060
1060
|
function getFileIconName(fileName, type2 = "file") {
|
|
@@ -1069,7 +1069,7 @@ function getFileIconName(fileName, type2 = "file") {
|
|
|
1069
1069
|
let icon = definitions.named[fileName] || definitions.files[fileName];
|
|
1070
1070
|
if (icon)
|
|
1071
1071
|
return icon;
|
|
1072
|
-
icon = getFileIconTypeFromExtension(fileName);
|
|
1072
|
+
icon = getFileIconTypeFromExtension(fileName) || void 0;
|
|
1073
1073
|
if (icon)
|
|
1074
1074
|
return icon;
|
|
1075
1075
|
for (const [partial, partialIcon] of Object.entries(definitions.partials)) {
|
|
@@ -1092,7 +1092,6 @@ function getFileIconTypeFromExtension(fileName) {
|
|
|
1092
1092
|
return;
|
|
1093
1093
|
extension = extension.slice(nextDotIndex);
|
|
1094
1094
|
}
|
|
1095
|
-
return void 0;
|
|
1096
1095
|
}
|
|
1097
1096
|
|
|
1098
1097
|
// src/node/utils/stringifyProp.ts
|
|
@@ -1141,17 +1140,15 @@ var codeTabs = (md, options = {}) => {
|
|
|
1141
1140
|
tabOpenRenderer: ({ index }, tokens, tokenIndex) => {
|
|
1142
1141
|
let foundFence = false;
|
|
1143
1142
|
for (let i = tokenIndex; i < tokens.length; i++) {
|
|
1144
|
-
const {
|
|
1145
|
-
if (
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
continue;
|
|
1151
|
-
}
|
|
1152
|
-
tokens[i].type = "code_tab_empty";
|
|
1153
|
-
tokens[i].hidden = true;
|
|
1143
|
+
const { type: type2 } = tokens[i];
|
|
1144
|
+
if (type2 === "code-tabs_tab_close")
|
|
1145
|
+
break;
|
|
1146
|
+
if ((type2 === "fence" || type2 === "import_code") && !foundFence) {
|
|
1147
|
+
foundFence = true;
|
|
1148
|
+
continue;
|
|
1154
1149
|
}
|
|
1150
|
+
tokens[i].type = "code_tab_empty";
|
|
1151
|
+
tokens[i].hidden = true;
|
|
1155
1152
|
}
|
|
1156
1153
|
return `<template #tab${index}="{ value, isActive }">`;
|
|
1157
1154
|
},
|
|
@@ -1244,7 +1241,7 @@ function resolveTreeNodeInfo(tokens, current, idx) {
|
|
|
1244
1241
|
}
|
|
1245
1242
|
function updateInlineToken(inline, info, icon) {
|
|
1246
1243
|
const children = inline.children;
|
|
1247
|
-
if (!children)
|
|
1244
|
+
if (!children || children.length === 0)
|
|
1248
1245
|
return;
|
|
1249
1246
|
const tokens = [];
|
|
1250
1247
|
const wrapperOpen = new Token("span_open", "span", 1);
|
|
@@ -1555,13 +1552,13 @@ var MANAGERS_CONFIG = {
|
|
|
1555
1552
|
deno: { cli: "deno install --frozen" }
|
|
1556
1553
|
}
|
|
1557
1554
|
};
|
|
1558
|
-
function npmToPlugins(md, options) {
|
|
1555
|
+
function npmToPlugins(md, options = {}) {
|
|
1559
1556
|
const type2 = "npm-to";
|
|
1560
1557
|
const validate = (info) => info.trim().startsWith(type2);
|
|
1561
1558
|
const opt = isArray(options) ? { tabs: options } : options;
|
|
1562
1559
|
const defaultTabs = opt.tabs?.length ? opt.tabs : DEFAULT_TABS;
|
|
1563
1560
|
const render = (tokens, idx) => {
|
|
1564
|
-
const { attrs: attrs2 } = resolveAttrs(tokens[idx].info.slice(type2.length
|
|
1561
|
+
const { attrs: attrs2 } = resolveAttrs(tokens[idx].info.trim().slice(type2.length));
|
|
1565
1562
|
const tabs2 = attrs2.tabs ? attrs2.tabs.split(/,\s*/) : defaultTabs;
|
|
1566
1563
|
if (tokens[idx].nesting === 1) {
|
|
1567
1564
|
const token = tokens[idx + 1];
|
|
@@ -1590,21 +1587,19 @@ function resolveNpmTo(lines, info, idx, tabs2) {
|
|
|
1590
1587
|
if (config && config[tab3]) {
|
|
1591
1588
|
const parsed = map[line] ??= parseLine(line);
|
|
1592
1589
|
const { cli, flags } = config[tab3];
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
args = args.replaceAll(key, value);
|
|
1599
|
-
}
|
|
1600
|
-
newLine += ` ${args.replace(/\s+-/g, " -").trim()}`;
|
|
1590
|
+
let newLine = `${parsed.env ? `${parsed.env} ` : ""}${cli}`;
|
|
1591
|
+
if (parsed.args && flags) {
|
|
1592
|
+
let args = parsed.args;
|
|
1593
|
+
for (const [key, value] of Object.entries(flags)) {
|
|
1594
|
+
args = args.replaceAll(key, value);
|
|
1601
1595
|
}
|
|
1602
|
-
|
|
1603
|
-
newLine += ` ${parsed.cmd}`;
|
|
1604
|
-
if (parsed.scriptArgs)
|
|
1605
|
-
newLine += ` ${parsed.scriptArgs}`;
|
|
1606
|
-
newLines.push(newLine.trim());
|
|
1596
|
+
newLine += ` ${args.replace(/\s+-/g, " -").trim()}`;
|
|
1607
1597
|
}
|
|
1598
|
+
if (parsed.cmd)
|
|
1599
|
+
newLine += ` ${parsed.cmd}`;
|
|
1600
|
+
if (parsed.scriptArgs)
|
|
1601
|
+
newLine += ` ${parsed.scriptArgs}`;
|
|
1602
|
+
newLines.push(newLine.trim());
|
|
1608
1603
|
} else {
|
|
1609
1604
|
newLines.push(line);
|
|
1610
1605
|
}
|
|
@@ -1627,10 +1622,11 @@ function findConfig(line) {
|
|
|
1627
1622
|
return void 0;
|
|
1628
1623
|
}
|
|
1629
1624
|
function validateTabs(tabs2) {
|
|
1625
|
+
tabs2 = tabs2.filter((tab3) => ALLOW_LIST.includes(tab3));
|
|
1630
1626
|
if (tabs2.length === 0) {
|
|
1631
1627
|
return DEFAULT_TABS;
|
|
1632
1628
|
}
|
|
1633
|
-
return tabs2
|
|
1629
|
+
return tabs2;
|
|
1634
1630
|
}
|
|
1635
1631
|
var LINE_REG = /(.*)(npm|npx)\s+(.*)/;
|
|
1636
1632
|
function parseLine(line) {
|
|
@@ -1638,27 +1634,34 @@ function parseLine(line) {
|
|
|
1638
1634
|
if (!match)
|
|
1639
1635
|
return false;
|
|
1640
1636
|
const [, env, cli, rest] = match;
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1637
|
+
const idx = rest.trim().indexOf(" ");
|
|
1638
|
+
if (cli === "npx") {
|
|
1639
|
+
let cmd = "";
|
|
1640
|
+
let scriptArgs = "";
|
|
1641
|
+
if (idx !== -1) {
|
|
1642
|
+
cmd = rest.slice(0, idx);
|
|
1643
|
+
scriptArgs = rest.slice(idx + 1).trim();
|
|
1644
|
+
} else {
|
|
1645
|
+
cmd = rest;
|
|
1646
|
+
}
|
|
1647
|
+
return { env, cli, cmd, scriptArgs };
|
|
1648
|
+
}
|
|
1644
1649
|
if (idx === -1)
|
|
1645
1650
|
return { env, cli: `${cli} ${rest.trim()}`, cmd: "" };
|
|
1646
1651
|
return { env, cli: `${cli} ${rest.slice(0, idx)}`, ...parseArgs(rest.slice(idx + 1)) };
|
|
1647
1652
|
}
|
|
1648
1653
|
function parseArgs(line) {
|
|
1649
1654
|
line = line?.trim();
|
|
1650
|
-
if (!line)
|
|
1651
|
-
return { cmd: "" };
|
|
1652
1655
|
const [npmArgs, scriptArgs] = line.split(/\s+--\s+/);
|
|
1653
1656
|
let cmd = "";
|
|
1654
1657
|
let args = "";
|
|
1655
1658
|
if (npmArgs[0] !== "-") {
|
|
1656
1659
|
if (npmArgs[0] === '"' || npmArgs[0] === "'") {
|
|
1657
1660
|
const idx = npmArgs.slice(1).indexOf(npmArgs[0]);
|
|
1658
|
-
cmd = npmArgs.slice(0, idx);
|
|
1659
|
-
args = npmArgs.slice(idx +
|
|
1661
|
+
cmd = npmArgs.slice(0, idx + 2);
|
|
1662
|
+
args = npmArgs.slice(idx + 2);
|
|
1660
1663
|
} else {
|
|
1661
|
-
const idx = npmArgs.indexOf(" ");
|
|
1664
|
+
const idx = npmArgs.indexOf(" -");
|
|
1662
1665
|
if (idx === -1) {
|
|
1663
1666
|
cmd = npmArgs;
|
|
1664
1667
|
} else {
|
|
@@ -1692,9 +1695,9 @@ function parseArgs(line) {
|
|
|
1692
1695
|
isNextValue = !isBool;
|
|
1693
1696
|
}
|
|
1694
1697
|
if (!isKey && !isNextValue) {
|
|
1695
|
-
cmd += `${value}
|
|
1698
|
+
cmd += `${value}`;
|
|
1696
1699
|
} else {
|
|
1697
|
-
newLine += `${value}${v
|
|
1700
|
+
newLine += `${value}${i !== npmArgs.length - 1 ? v : ""}`;
|
|
1698
1701
|
if (!isKey && isNextValue) {
|
|
1699
1702
|
isNextValue = false;
|
|
1700
1703
|
}
|
|
@@ -1706,7 +1709,7 @@ function parseArgs(line) {
|
|
|
1706
1709
|
}
|
|
1707
1710
|
args = newLine;
|
|
1708
1711
|
}
|
|
1709
|
-
return { cmd, args: args.trim(), scriptArgs };
|
|
1712
|
+
return { cmd: cmd.trim(), args: args.trim(), scriptArgs };
|
|
1710
1713
|
}
|
|
1711
1714
|
|
|
1712
1715
|
// src/node/container/tabs.ts
|
|
@@ -1749,7 +1752,10 @@ async function containerPlugin(app, md, options) {
|
|
|
1749
1752
|
|
|
1750
1753
|
// src/node/embed/caniuse.ts
|
|
1751
1754
|
import container5 from "markdown-it-container";
|
|
1755
|
+
|
|
1756
|
+
// src/node/utils/nanoid.ts
|
|
1752
1757
|
import { customAlphabet } from "nanoid";
|
|
1758
|
+
var nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 5);
|
|
1753
1759
|
|
|
1754
1760
|
// src/node/embed/createEmbedRuleBlock.ts
|
|
1755
1761
|
function createEmbedRuleBlock(md, {
|
|
@@ -1796,7 +1802,6 @@ function createEmbedRuleBlock(md, {
|
|
|
1796
1802
|
}
|
|
1797
1803
|
|
|
1798
1804
|
// src/node/embed/caniuse.ts
|
|
1799
|
-
var nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 5);
|
|
1800
1805
|
var UNDERLINE_RE = /_+/g;
|
|
1801
1806
|
var caniusePlugin = (md, { mode: defaultMode = "embed" } = {}) => {
|
|
1802
1807
|
createEmbedRuleBlock(md, {
|
|
@@ -1874,7 +1879,7 @@ var codepenPlugin = (md) => {
|
|
|
1874
1879
|
createEmbedRuleBlock(md, {
|
|
1875
1880
|
type: "codepen",
|
|
1876
1881
|
syntaxPattern: /^@\[codepen([^\]]*)\]\(([^)]*)\)/,
|
|
1877
|
-
meta: ([, info
|
|
1882
|
+
meta: ([, info, source]) => {
|
|
1878
1883
|
const { attrs: attrs2 } = resolveAttrs(info);
|
|
1879
1884
|
const [user, slash] = source.split("/");
|
|
1880
1885
|
return {
|
|
@@ -1885,7 +1890,7 @@ var codepenPlugin = (md) => {
|
|
|
1885
1890
|
title: attrs2.title,
|
|
1886
1891
|
preview: attrs2.preview,
|
|
1887
1892
|
editable: attrs2.editable,
|
|
1888
|
-
tab: attrs2.tab
|
|
1893
|
+
tab: attrs2.tab || "result",
|
|
1889
1894
|
theme: attrs2.theme
|
|
1890
1895
|
};
|
|
1891
1896
|
},
|
|
@@ -1895,9 +1900,7 @@ var codepenPlugin = (md) => {
|
|
|
1895
1900
|
if (meta.editable) {
|
|
1896
1901
|
params.set("editable", "true");
|
|
1897
1902
|
}
|
|
1898
|
-
|
|
1899
|
-
params.set("default-tab", meta.tab);
|
|
1900
|
-
}
|
|
1903
|
+
params.set("default-tab", meta.tab);
|
|
1901
1904
|
if (meta.theme) {
|
|
1902
1905
|
params.set("theme-id", meta.theme);
|
|
1903
1906
|
}
|
|
@@ -1914,7 +1917,7 @@ var codeSandboxPlugin = (md) => {
|
|
|
1914
1917
|
createEmbedRuleBlock(md, {
|
|
1915
1918
|
type: "codesandbox",
|
|
1916
1919
|
syntaxPattern: /^@\[codesandbox(?:\s+(embed|button))?([^\]]*)\]\(([^)]*)\)/,
|
|
1917
|
-
meta([, type2, info
|
|
1920
|
+
meta([, type2, info, source]) {
|
|
1918
1921
|
const { attrs: attrs2 } = resolveAttrs(info);
|
|
1919
1922
|
const [profile, filepath2 = ""] = source.split("#");
|
|
1920
1923
|
const [user, id] = profile.includes("/") ? profile.split("/") : ["", profile];
|
|
@@ -1942,7 +1945,7 @@ var jsfiddlePlugin = (md) => {
|
|
|
1942
1945
|
createEmbedRuleBlock(md, {
|
|
1943
1946
|
type: "jsfiddle",
|
|
1944
1947
|
syntaxPattern: /^@\[jsfiddle([^\]]*)\]\(([^)]*)\)/,
|
|
1945
|
-
meta([, info
|
|
1948
|
+
meta([, info, source]) {
|
|
1946
1949
|
const { attrs: attrs2 } = resolveAttrs(info);
|
|
1947
1950
|
const [user, id] = source.split("/");
|
|
1948
1951
|
return {
|
|
@@ -1955,7 +1958,7 @@ var jsfiddlePlugin = (md) => {
|
|
|
1955
1958
|
theme: attrs2.theme || "dark"
|
|
1956
1959
|
};
|
|
1957
1960
|
},
|
|
1958
|
-
content: ({ title
|
|
1961
|
+
content: ({ title, height, width, user, id, tab: tab3, theme }) => {
|
|
1959
1962
|
theme = theme === "dark" ? "/dark/" : "";
|
|
1960
1963
|
const link = `https://jsfiddle.net/${user}/${id}/embedded/${tab3}${theme}`;
|
|
1961
1964
|
const style = `width:${width};height:${height};margin:16px auto;border:none;border-radius:5px;`;
|
|
@@ -1992,7 +1995,7 @@ var pdfPlugin = (md) => {
|
|
|
1992
1995
|
type: "pdf",
|
|
1993
1996
|
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
1994
1997
|
syntaxPattern: /^@\[pdf(?:\s+(\d+))?([^\]]*)\]\(([^)]*)\)/,
|
|
1995
|
-
meta([, page, info
|
|
1998
|
+
meta([, page, info, src]) {
|
|
1996
1999
|
const { attrs: attrs2 } = resolveAttrs(info);
|
|
1997
2000
|
return {
|
|
1998
2001
|
src,
|
|
@@ -2020,7 +2023,7 @@ function timeToSeconds(time) {
|
|
|
2020
2023
|
return 0;
|
|
2021
2024
|
if (Number.parseFloat(time) === Number(time))
|
|
2022
2025
|
return Number(time);
|
|
2023
|
-
const [s, m, h] = time.split(
|
|
2026
|
+
const [s, m, h = 0] = time.split(/\s*:\s*/).reverse().map((n) => Number(n) || 0);
|
|
2024
2027
|
return s + m * 60 + h * 3600;
|
|
2025
2028
|
}
|
|
2026
2029
|
|
|
@@ -2032,13 +2035,13 @@ var bilibiliPlugin = (md) => {
|
|
|
2032
2035
|
name: "video_bilibili",
|
|
2033
2036
|
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
2034
2037
|
syntaxPattern: /^@\[bilibili(?:\s+p(\d+))?([^\]]*)\]\(([^)]*)\)/,
|
|
2035
|
-
meta([, page, info
|
|
2038
|
+
meta([, page, info, source]) {
|
|
2036
2039
|
const { attrs: attrs2 } = resolveAttrs(info);
|
|
2037
2040
|
const ids = source.trim().split(/\s+/);
|
|
2038
2041
|
const bvid = ids.find((id) => id.startsWith("BV"));
|
|
2039
2042
|
const [aid, cid] = ids.filter((id) => !id.startsWith("BV"));
|
|
2040
2043
|
return {
|
|
2041
|
-
page: +page
|
|
2044
|
+
page: +page,
|
|
2042
2045
|
bvid,
|
|
2043
2046
|
aid,
|
|
2044
2047
|
cid,
|
|
@@ -2082,7 +2085,7 @@ var youtubePlugin = (md) => {
|
|
|
2082
2085
|
type: "youtube",
|
|
2083
2086
|
name: "video_youtube",
|
|
2084
2087
|
syntaxPattern: /^@\[youtube([^\]]*)\]\(([^)]*)\)/,
|
|
2085
|
-
meta([, info
|
|
2088
|
+
meta([, info, id]) {
|
|
2086
2089
|
const { attrs: attrs2 } = resolveAttrs(info);
|
|
2087
2090
|
return {
|
|
2088
2091
|
id,
|
|
@@ -2189,13 +2192,12 @@ function createTokenizer(options) {
|
|
|
2189
2192
|
state.posMax = state.pos;
|
|
2190
2193
|
state.pos = start + 2;
|
|
2191
2194
|
const [name, opt = ""] = content.split(/\s+/);
|
|
2192
|
-
const [size
|
|
2195
|
+
const [size, color = options.color] = opt.split("/");
|
|
2193
2196
|
const icon = state.push("vp_iconify_open", "VPIcon", 1);
|
|
2194
2197
|
icon.markup = openTag;
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
icon.attrSet("size", String(size));
|
|
2198
|
+
icon.attrSet("name", name);
|
|
2199
|
+
if (size || options.size)
|
|
2200
|
+
icon.attrSet("size", String(size || options.size));
|
|
2199
2201
|
if (color)
|
|
2200
2202
|
icon.attrSet("color", color);
|
|
2201
2203
|
const close = state.push("vp_iconify_close", "VPIcon", -1);
|
package/lib/shared/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-plugin-md-power",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.108",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"markdown-it-container": "^4.0.0",
|
|
54
54
|
"nanoid": "^5.0.7",
|
|
55
55
|
"shiki": "^1.22.0",
|
|
56
|
-
"tm-grammars": "^1.18.
|
|
57
|
-
"tm-themes": "^1.8.
|
|
58
|
-
"vue": "^3.5.
|
|
56
|
+
"tm-grammars": "^1.18.2",
|
|
57
|
+
"tm-themes": "^1.8.8",
|
|
58
|
+
"vue": "^3.5.12"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/markdown-it": "^14.1.2"
|