vuepress-plugin-md-power 1.0.0-rc.162 → 1.0.0-rc.164
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/client/components/ArtPlayer.vue +1 -1
- package/lib/client/components/CodeSandbox.vue +6 -1
- package/lib/client/components/FileTreeNode.vue +4 -0
- package/lib/client/components/Replit.vue +5 -0
- package/lib/client/components/VPVideoEmbed.vue +5 -0
- package/lib/client/composables/audio.js +1 -2
- package/lib/client/composables/codeRepl.js +2 -5
- package/lib/client/composables/pdf.js +3 -7
- package/lib/client/composables/{rustRepl-iGLjb94D.js → rustRepl-CARlbZyO.js} +2 -4
- package/lib/client/composables/rustRepl.js +1 -1
- package/lib/client/index.d.ts +1 -2
- package/lib/client/utils/http.js +3 -5
- package/lib/node/index.js +41 -64
- package/package.json +12 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type ArtPlayer from 'artplayer'
|
|
3
|
-
import type { Option as ArtPlayerInitOptions } from 'artplayer
|
|
3
|
+
import type { Option as ArtPlayerInitOptions } from 'artplayer'
|
|
4
4
|
import { isLinkHttp } from '@vuepress/helper/client'
|
|
5
5
|
import { useCssVar } from '@vueuse/core'
|
|
6
6
|
import { onMounted, onUnmounted, ref, toRefs } from 'vue'
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import type { CodeSandboxTokenMeta } from '../../shared/index.js'
|
|
3
3
|
import { computed } from 'vue'
|
|
4
4
|
|
|
5
|
+
defineOptions({
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
})
|
|
8
|
+
|
|
5
9
|
const props = defineProps<CodeSandboxTokenMeta>()
|
|
6
10
|
|
|
7
11
|
const EMBED_LINK = 'https://codesandbox.io/embed/'
|
|
@@ -37,9 +41,10 @@ const source = computed(() => {
|
|
|
37
41
|
<iframe
|
|
38
42
|
:src="source" class="code-sandbox-iframe" :title="title || 'CodeSandbox'" :allow="ALLOW" :sandbox="SANDBOX"
|
|
39
43
|
:style="{ width, height }"
|
|
44
|
+
v-bind="$attrs"
|
|
40
45
|
/>
|
|
41
46
|
</ClientOnly>
|
|
42
|
-
<p v-else>
|
|
47
|
+
<p v-else v-bind="$attrs">
|
|
43
48
|
<a class="code-sandbox-link no-icon" :href="source" target="_blank" rel="noopener noreferrer" :aria-label="title || 'CodeSandbox'">
|
|
44
49
|
<svg xmlns="http://www.w3.org/2000/svg" width="165" height="32" viewBox="0 0 165 32" fill="none">
|
|
45
50
|
<rect width="165" height="32" rx="4" fill="#E3FF73" />
|
|
@@ -93,6 +93,7 @@ function toggle(ev: MouseEvent) {
|
|
|
93
93
|
gap: 8px;
|
|
94
94
|
align-items: center;
|
|
95
95
|
justify-content: flex-start;
|
|
96
|
+
min-width: max-content;
|
|
96
97
|
height: 28px;
|
|
97
98
|
padding: 2px 0;
|
|
98
99
|
margin: 0 0 0 16px;
|
|
@@ -167,6 +168,8 @@ function toggle(ev: MouseEvent) {
|
|
|
167
168
|
|
|
168
169
|
.vp-file-tree .vp-file-tree-info .name {
|
|
169
170
|
position: relative;
|
|
171
|
+
flex-shrink: 99;
|
|
172
|
+
min-width: 0;
|
|
170
173
|
font-family: var(--vp-font-family-mono);
|
|
171
174
|
}
|
|
172
175
|
|
|
@@ -208,6 +211,7 @@ function toggle(ev: MouseEvent) {
|
|
|
208
211
|
|
|
209
212
|
.vp-file-tree .vp-file-tree-node .group {
|
|
210
213
|
position: relative;
|
|
214
|
+
min-width: max-content;
|
|
211
215
|
margin-left: 28px;
|
|
212
216
|
}
|
|
213
217
|
|
|
@@ -4,6 +4,10 @@ import { useDarkMode } from '@vuepress/helper/client'
|
|
|
4
4
|
import { computed, ref } from 'vue'
|
|
5
5
|
import Loading from './icons/Loading.vue'
|
|
6
6
|
|
|
7
|
+
defineOptions({
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
})
|
|
10
|
+
|
|
7
11
|
const props = defineProps<ReplitTokenMeta>()
|
|
8
12
|
|
|
9
13
|
// magic height
|
|
@@ -37,6 +41,7 @@ function onload() {
|
|
|
37
41
|
:src="link"
|
|
38
42
|
:title="title || 'Replit'"
|
|
39
43
|
:style="{ width, height }"
|
|
44
|
+
v-bind="$attrs"
|
|
40
45
|
allowtransparency="true"
|
|
41
46
|
allowfullscree="true"
|
|
42
47
|
@load="onload"
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { toRefs } from 'vue'
|
|
3
3
|
import { useSize } from '../composables/size.js'
|
|
4
4
|
|
|
5
|
+
defineOptions({
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
})
|
|
8
|
+
|
|
5
9
|
const props = defineProps<{
|
|
6
10
|
src: string
|
|
7
11
|
title: string
|
|
@@ -26,6 +30,7 @@ const { el, width, height, resize } = useSize(options)
|
|
|
26
30
|
:src="src"
|
|
27
31
|
:title="title || type"
|
|
28
32
|
:style="{ width, height }"
|
|
33
|
+
v-bind="$attrs"
|
|
29
34
|
:allow="IFRAME_ALLOW"
|
|
30
35
|
@load="resize"
|
|
31
36
|
/>
|
|
@@ -120,8 +120,7 @@ function useAudioPlayer(source, options = {}) {
|
|
|
120
120
|
if (!bufferedRanges.length) return 0;
|
|
121
121
|
const buff = bufferedRanges.find((buff$1) => buff$1.start < player.currentTime && buff$1.end > player.currentTime);
|
|
122
122
|
if (buff) return buff.end;
|
|
123
|
-
|
|
124
|
-
return last.end;
|
|
123
|
+
return bufferedRanges[bufferedRanges.length - 1].end;
|
|
125
124
|
}
|
|
126
125
|
function isValidDuration(duration$1) {
|
|
127
126
|
if (duration$1 && !Number.isNaN(duration$1) && duration$1 !== Number.POSITIVE_INFINITY && duration$1 !== Number.NEGATIVE_INFINITY) return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rustExecute } from "./rustRepl-
|
|
1
|
+
import { rustExecute } from "./rustRepl-CARlbZyO.js";
|
|
2
2
|
import { onMounted, ref } from "vue";
|
|
3
3
|
import { http } from "../utils/http.js";
|
|
4
4
|
import { sleep } from "../utils/sleep.js";
|
|
@@ -55,10 +55,7 @@ function useCodeRepl(el) {
|
|
|
55
55
|
const error = ref("");
|
|
56
56
|
const backendVersion = ref("");
|
|
57
57
|
onMounted(() => {
|
|
58
|
-
if (el.value)
|
|
59
|
-
const info = resolveCodeInfo(el.value);
|
|
60
|
-
lang.value = info.lang;
|
|
61
|
-
}
|
|
58
|
+
if (el.value) lang.value = resolveCodeInfo(el.value).lang;
|
|
62
59
|
});
|
|
63
60
|
const executeMap = {
|
|
64
61
|
kotlin: executeKotlin,
|
|
@@ -6,12 +6,11 @@ import { pluginOptions } from "../options.js";
|
|
|
6
6
|
//#region src/client/composables/pdf.ts
|
|
7
7
|
function queryStringify(options) {
|
|
8
8
|
const { page, noToolbar, zoom } = options;
|
|
9
|
-
|
|
9
|
+
let queryString = [
|
|
10
10
|
`page=${page}`,
|
|
11
11
|
`toolbar=${noToolbar ? 0 : 1}`,
|
|
12
12
|
`zoom=${zoom}`
|
|
13
|
-
];
|
|
14
|
-
let queryString = params.join("&");
|
|
13
|
+
].join("&");
|
|
15
14
|
if (queryString) queryString = `#${queryString}`;
|
|
16
15
|
return queryString;
|
|
17
16
|
}
|
|
@@ -43,10 +42,7 @@ function usePDF(el, url, options) {
|
|
|
43
42
|
const isFirefoxWithPDFJS = !isMobileDevice && /firefox/iu.test(userAgent) && userAgent.split("rv:").length > 1 ? Number.parseInt(userAgent.split("rv:")[1].split(".")[0], 10) > 18 : false;
|
|
44
43
|
const supportsPDFs = !isMobileDevice && (isModernBrowser || isFirefoxWithPDFJS);
|
|
45
44
|
if (!url) return;
|
|
46
|
-
if (supportsPDFs || !isMobileDevice)
|
|
47
|
-
const embedType = isSafariDesktop ? "iframe" : "embed";
|
|
48
|
-
return renderPDF(el, url, embedType, options);
|
|
49
|
-
}
|
|
45
|
+
if (supportsPDFs || !isMobileDevice) return renderPDF(el, url, isSafariDesktop ? "iframe" : "embed", options);
|
|
50
46
|
return renderPDF(el, url, "pdfjs", options);
|
|
51
47
|
}
|
|
52
48
|
|
|
@@ -33,8 +33,7 @@ function connect() {
|
|
|
33
33
|
tryOnScopeDispose(() => ws?.close());
|
|
34
34
|
return new Promise((resolve) => {
|
|
35
35
|
function connected(e) {
|
|
36
|
-
|
|
37
|
-
if (data.type === payloadType.connected) {
|
|
36
|
+
if (JSON.parse(e.data).type === payloadType.connected) {
|
|
38
37
|
ws?.removeEventListener("message", connected);
|
|
39
38
|
resolve();
|
|
40
39
|
}
|
|
@@ -66,8 +65,7 @@ async function rustExecute(code, { onEnd, onError, onStderr, onStdout, onBegin }
|
|
|
66
65
|
let stdout = "";
|
|
67
66
|
let stderr = "";
|
|
68
67
|
function onMessage(e) {
|
|
69
|
-
const
|
|
70
|
-
const { type, payload: payload$1, meta: _meta = {} } = data;
|
|
68
|
+
const { type, payload: payload$1, meta: _meta = {} } = JSON.parse(e.data);
|
|
71
69
|
if (_meta.sequenceNumber !== meta.sequenceNumber) return;
|
|
72
70
|
if (type === payloadType.execute.begin) onBegin?.();
|
|
73
71
|
if (type === payloadType.execute.stdout) {
|
package/lib/client/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "../shared/index.js";
|
|
2
|
-
export {};
|
|
1
|
+
export * from "../shared/index.js";
|
package/lib/client/utils/http.js
CHANGED
|
@@ -3,16 +3,14 @@ const http = {
|
|
|
3
3
|
get: async (url, query) => {
|
|
4
4
|
const _url = new URL(url);
|
|
5
5
|
if (query) for (const [key, value] of Object.entries(query)) _url.searchParams.append(key, value);
|
|
6
|
-
|
|
7
|
-
return await res.json();
|
|
6
|
+
return await (await fetch(_url.toString())).json();
|
|
8
7
|
},
|
|
9
8
|
post: async (url, data) => {
|
|
10
|
-
|
|
9
|
+
return await (await fetch(url, {
|
|
11
10
|
method: "POST",
|
|
12
11
|
headers: { "Content-Type": "application/json" },
|
|
13
12
|
body: data ? JSON.stringify(data) : void 0
|
|
14
|
-
});
|
|
15
|
-
return await res.json();
|
|
13
|
+
})).json();
|
|
16
14
|
}
|
|
17
15
|
};
|
|
18
16
|
|
package/lib/node/index.js
CHANGED
|
@@ -901,13 +901,13 @@ function createCodeTabIconGetter(options = {}) {
|
|
|
901
901
|
const { named, extensions } = isPlainObject(options.icon) ? options.icon : {};
|
|
902
902
|
return function getIcon(filename) {
|
|
903
903
|
if (named === false && definitions.named[filename]) return void 0;
|
|
904
|
-
if (extensions === false && getFileIconTypeFromExtension(filename)) return
|
|
904
|
+
if (extensions === false && getFileIconTypeFromExtension(filename)) return;
|
|
905
905
|
const hasNamed = named && named.length;
|
|
906
906
|
const hasExt = extensions && extensions.length;
|
|
907
907
|
if (hasNamed || hasExt) {
|
|
908
908
|
if (hasNamed && named.includes(filename)) return definitions.named[filename];
|
|
909
909
|
if (hasExt && extensions.some((ext) => filename.endsWith(ext))) return getFileIconTypeFromExtension(filename);
|
|
910
|
-
return
|
|
910
|
+
return;
|
|
911
911
|
}
|
|
912
912
|
return getFileIconName(filename);
|
|
913
913
|
};
|
|
@@ -1031,8 +1031,7 @@ async function imageSizePlugin(app, md, type = false) {
|
|
|
1031
1031
|
if (!size) return raw;
|
|
1032
1032
|
attrs$1.width = size.width;
|
|
1033
1033
|
attrs$1.height = size.height;
|
|
1034
|
-
|
|
1035
|
-
return `<img ${imgAttrs}>`;
|
|
1034
|
+
return `<img ${Object.entries(attrs$1).map(([key, value]) => typeof value === "boolean" ? key : `${key}="${value}"`).join(" ")}>`;
|
|
1036
1035
|
});
|
|
1037
1036
|
return rawHtmlRule(tokens, idx, options, env, self);
|
|
1038
1037
|
};
|
|
@@ -1250,18 +1249,21 @@ function parseRect(str, unit = "px") {
|
|
|
1250
1249
|
|
|
1251
1250
|
//#endregion
|
|
1252
1251
|
//#region src/node/utils/stringifyAttrs.ts
|
|
1253
|
-
function stringifyAttrs(attrs$1,
|
|
1252
|
+
function stringifyAttrs(attrs$1, withUndefinedOrNull = false, forceStringify = []) {
|
|
1254
1253
|
const result = Object.entries(attrs$1).map(([key, value]) => {
|
|
1255
1254
|
const k = kebabCase(key);
|
|
1256
|
-
if (isUndefined(value) || value === "undefined") return
|
|
1257
|
-
if (isNull(value) || value === "null") return
|
|
1255
|
+
if (isUndefined(value) || value === "undefined") return withUndefinedOrNull ? `:${k}="undefined"` : "";
|
|
1256
|
+
if (isNull(value) || value === "null") return withUndefinedOrNull ? `:${k}="null"` : "";
|
|
1258
1257
|
if (value === "true") value = true;
|
|
1259
1258
|
if (value === "false") value = false;
|
|
1260
1259
|
if (isBoolean(value)) return value ? `${k}` : "";
|
|
1261
1260
|
if (isNumber(value)) return `:${k}="${value}"`;
|
|
1262
|
-
if (isString(value) && (value[0] === "{" || value[0] === "["))
|
|
1263
|
-
|
|
1264
|
-
|
|
1261
|
+
if (isString(value) && (value[0] === "{" || value[0] === "[")) {
|
|
1262
|
+
const v = value.replaceAll("\"", "'");
|
|
1263
|
+
if (forceStringify.includes(key)) return `${k}="${v}"`;
|
|
1264
|
+
return `:${k}="${v}"`;
|
|
1265
|
+
}
|
|
1266
|
+
return `${key[0] === ":" ? ":" : ""}${k}="${String(value)}"`;
|
|
1265
1267
|
}).filter(Boolean).join(" ");
|
|
1266
1268
|
return result ? ` ${result}` : "";
|
|
1267
1269
|
}
|
|
@@ -1431,7 +1433,7 @@ function codeTreePlugin(md, app, options = {}) {
|
|
|
1431
1433
|
expanded: true,
|
|
1432
1434
|
filepath: node.filepath
|
|
1433
1435
|
};
|
|
1434
|
-
return `<FileTreeNode${stringifyAttrs(props)}>
|
|
1436
|
+
return `<FileTreeNode${stringifyAttrs(props, false, ["filename", "filepath"])}>
|
|
1435
1437
|
<template #icon><VPIcon provider="iconify" name="${getIcon(node.filename, props.type, mode)}" /></template>
|
|
1436
1438
|
${node.children?.length ? renderFileTree(node.children, mode) : ""}
|
|
1437
1439
|
</FileTreeNode>`;
|
|
@@ -1493,8 +1495,7 @@ function codeTreePlugin(md, app, options = {}) {
|
|
|
1493
1495
|
]
|
|
1494
1496
|
}).sort((a, b) => {
|
|
1495
1497
|
const al = a.split("/").length;
|
|
1496
|
-
|
|
1497
|
-
return bl - al;
|
|
1498
|
+
return b.split("/").length - al;
|
|
1498
1499
|
});
|
|
1499
1500
|
props.entryFile ||= files[0];
|
|
1500
1501
|
const codeContent = files.map((file) => {
|
|
@@ -1515,21 +1516,19 @@ function codeTreePlugin(md, app, options = {}) {
|
|
|
1515
1516
|
* @param page vuepress 页面对象
|
|
1516
1517
|
*/
|
|
1517
1518
|
function extendsPageWithCodeTree(page) {
|
|
1518
|
-
const
|
|
1519
|
-
const codeTreeFiles = markdownEnv.codeTreeFiles ?? [];
|
|
1519
|
+
const codeTreeFiles = page.markdownEnv.codeTreeFiles ?? [];
|
|
1520
1520
|
if (codeTreeFiles.length) page.deps.push(...codeTreeFiles);
|
|
1521
1521
|
}
|
|
1522
1522
|
|
|
1523
1523
|
//#endregion
|
|
1524
1524
|
//#region src/node/container/align.ts
|
|
1525
1525
|
function alignPlugin(md) {
|
|
1526
|
-
const
|
|
1526
|
+
for (const name of [
|
|
1527
1527
|
"left",
|
|
1528
1528
|
"center",
|
|
1529
1529
|
"right",
|
|
1530
1530
|
"justify"
|
|
1531
|
-
];
|
|
1532
|
-
for (const name of alignList) createContainerPlugin(md, name, { before: () => `<div style="text-align:${name}">` });
|
|
1531
|
+
]) createContainerPlugin(md, name, { before: () => `<div style="text-align:${name}">` });
|
|
1533
1532
|
createContainerPlugin(md, "flex", { before: (info) => {
|
|
1534
1533
|
const { attrs: attrs$1 } = resolveAttrs(info);
|
|
1535
1534
|
const styles = ["margin:16px 0;display:flex"];
|
|
@@ -1666,8 +1665,7 @@ function collapsePlugin(md) {
|
|
|
1666
1665
|
after: () => `</VPCollapse>`
|
|
1667
1666
|
});
|
|
1668
1667
|
md.renderer.rules.collapse_item_open = (tokens, idx) => {
|
|
1669
|
-
const
|
|
1670
|
-
const { expand, index } = token.meta;
|
|
1668
|
+
const { expand, index } = tokens[idx].meta;
|
|
1671
1669
|
return `<VPCollapseItem${stringifyAttrs({
|
|
1672
1670
|
expand,
|
|
1673
1671
|
index
|
|
@@ -1692,14 +1690,12 @@ function parseCollapse(tokens, index, attrs$1) {
|
|
|
1692
1690
|
listStack.pop();
|
|
1693
1691
|
if (listStack.length === 0) token.hidden = true;
|
|
1694
1692
|
} else if (token.type === "list_item_open") {
|
|
1695
|
-
|
|
1696
|
-
if (currentLevel === 1) {
|
|
1693
|
+
if (listStack.length === 1) {
|
|
1697
1694
|
token.type = "collapse_item_open";
|
|
1698
1695
|
tokens[i + 1].type = "collapse_item_title_open";
|
|
1699
1696
|
tokens[i + 3].type = "collapse_item_title_close";
|
|
1700
1697
|
idx++;
|
|
1701
|
-
const
|
|
1702
|
-
const firstToken = inlineToken.children[0];
|
|
1698
|
+
const firstToken = tokens[i + 2].children[0];
|
|
1703
1699
|
let flag = "";
|
|
1704
1700
|
let expand;
|
|
1705
1701
|
if (firstToken.type === "text") firstToken.content = firstToken.content.trim().replace(/^:[+\-]\s*/, (match) => {
|
|
@@ -1720,8 +1716,7 @@ function parseCollapse(tokens, index, attrs$1) {
|
|
|
1720
1716
|
};
|
|
1721
1717
|
}
|
|
1722
1718
|
} else if (token.type === "list_item_close") {
|
|
1723
|
-
|
|
1724
|
-
if (currentLevel === 1) token.type = "collapse_item_close";
|
|
1719
|
+
if (listStack.length === 1) token.type = "collapse_item_close";
|
|
1725
1720
|
}
|
|
1726
1721
|
}
|
|
1727
1722
|
if (attrs$1.accordion && attrs$1.expand && !hashExpand) defaultIndex = 0;
|
|
@@ -1766,13 +1761,12 @@ function fieldPlugin(md) {
|
|
|
1766
1761
|
before: (info) => {
|
|
1767
1762
|
const { attrs: attrs$1 } = resolveAttrs(info);
|
|
1768
1763
|
const { name, type, required, optional, deprecated, default: defaultValue } = attrs$1;
|
|
1769
|
-
|
|
1764
|
+
return `<VPField${stringifyAttrs({
|
|
1770
1765
|
name,
|
|
1771
1766
|
required,
|
|
1772
1767
|
optional,
|
|
1773
1768
|
deprecated
|
|
1774
|
-
})
|
|
1775
|
-
return `<VPField${props}${!isUndefined(type) ? ` type="${type}"` : ""}${!isUndefined(defaultValue) ? ` default-value="${defaultValue}"` : ""}>`;
|
|
1769
|
+
})}${!isUndefined(type) ? ` type="${type}"` : ""}${!isUndefined(defaultValue) ? ` default-value="${defaultValue}"` : ""}>`;
|
|
1776
1770
|
},
|
|
1777
1771
|
after: () => "</VPField>"
|
|
1778
1772
|
});
|
|
@@ -1885,15 +1879,14 @@ function fileTreePlugin(md, options = {}) {
|
|
|
1885
1879
|
const nodeType = children.length > 0 ? "folder" : type;
|
|
1886
1880
|
const renderedComment = comment ? `<template #comment>${md.renderInline(comment.replaceAll("#", "#"))}</template>` : "";
|
|
1887
1881
|
const renderedIcon = !isOmit ? `<template #icon><VPIcon provider="iconify" name="${getIcon(filename, nodeType, meta.icon)}" /></template>` : "";
|
|
1888
|
-
|
|
1882
|
+
return `<FileTreeNode${stringifyAttrs({
|
|
1889
1883
|
expanded: nodeType === "folder" ? expanded : false,
|
|
1890
1884
|
focus,
|
|
1891
1885
|
type: nodeType,
|
|
1892
1886
|
diff,
|
|
1893
1887
|
filename,
|
|
1894
1888
|
level
|
|
1895
|
-
}
|
|
1896
|
-
return `<FileTreeNode${stringifyAttrs(props)}>
|
|
1889
|
+
}, false, ["filename"])}>
|
|
1897
1890
|
${renderedIcon}${renderedComment}${children.length > 0 ? renderFileTree(children, meta) : ""}
|
|
1898
1891
|
</FileTreeNode>`;
|
|
1899
1892
|
}).join("\n");
|
|
@@ -1953,7 +1946,6 @@ async function read(file) {
|
|
|
1953
1946
|
const content = await promises.readFile(file, "utf-8");
|
|
1954
1947
|
return JSON.parse(content);
|
|
1955
1948
|
} catch {}
|
|
1956
|
-
return void 0;
|
|
1957
1949
|
}
|
|
1958
1950
|
|
|
1959
1951
|
//#endregion
|
|
@@ -2321,7 +2313,6 @@ function resolveNpmTo(lines, info, idx, tabs$1) {
|
|
|
2321
2313
|
*/
|
|
2322
2314
|
function findConfig(line) {
|
|
2323
2315
|
for (const { pattern,...config } of Object.values(MANAGERS_CONFIG)) if (pattern.test(line)) return config;
|
|
2324
|
-
return void 0;
|
|
2325
2316
|
}
|
|
2326
2317
|
/**
|
|
2327
2318
|
* 校验 tabs 合法性,返回允许的包管理器列表
|
|
@@ -2554,8 +2545,7 @@ function timelinePlugin(md) {
|
|
|
2554
2545
|
after: () => "</VPTimeline>"
|
|
2555
2546
|
});
|
|
2556
2547
|
md.renderer.rules.timeline_item_open = (tokens, idx) => {
|
|
2557
|
-
const
|
|
2558
|
-
const attrs$1 = token.meta;
|
|
2548
|
+
const attrs$1 = tokens[idx].meta;
|
|
2559
2549
|
attrs$1.card ??= void 0;
|
|
2560
2550
|
const icon = attrs$1.icon;
|
|
2561
2551
|
return `<VPTimelineItem${stringifyAttrs(attrs$1, true)}>${icon ? `<template #icon><VPIcon provider="iconify" name="${icon}"/></template>` : ""}`;
|
|
@@ -2576,8 +2566,7 @@ function parseTimeline(tokens, index) {
|
|
|
2576
2566
|
listStack.pop();
|
|
2577
2567
|
if (listStack.length === 0) token.hidden = true;
|
|
2578
2568
|
} else if (token.type === "list_item_open") {
|
|
2579
|
-
|
|
2580
|
-
if (currentLevel === 1) {
|
|
2569
|
+
if (listStack.length === 1) {
|
|
2581
2570
|
token.type = "timeline_item_open";
|
|
2582
2571
|
tokens[i + 1].type = "timeline_item_title_open";
|
|
2583
2572
|
tokens[i + 3].type = "timeline_item_title_close";
|
|
@@ -2590,8 +2579,7 @@ function parseTimeline(tokens, index) {
|
|
|
2590
2579
|
} else token.meta = {};
|
|
2591
2580
|
}
|
|
2592
2581
|
} else if (token.type === "list_item_close") {
|
|
2593
|
-
|
|
2594
|
-
if (currentLevel === 1) token.type = "timeline_item_close";
|
|
2582
|
+
if (listStack.length === 1) token.type = "timeline_item_close";
|
|
2595
2583
|
}
|
|
2596
2584
|
}
|
|
2597
2585
|
}
|
|
@@ -2612,14 +2600,12 @@ function extractTimelineAttributes(rawText) {
|
|
|
2612
2600
|
if (!keyMatch) break;
|
|
2613
2601
|
const matchedKey = keyMatch[1].toLowerCase();
|
|
2614
2602
|
if (!attrKeys.includes(matchedKey)) break;
|
|
2615
|
-
const
|
|
2616
|
-
const keyEnd = keyStart + keyMatch[0].length;
|
|
2603
|
+
const keyEnd = keyMatch.index + keyMatch[0].length;
|
|
2617
2604
|
buffer = buffer.slice(keyEnd);
|
|
2618
2605
|
let valueEnd = buffer.search(RE_SEARCH_KEY);
|
|
2619
2606
|
/* istanbul ignore if -- @preserve */
|
|
2620
2607
|
if (valueEnd === -1) valueEnd = buffer.length;
|
|
2621
|
-
|
|
2622
|
-
attrs$1[matchedKey] = value.replace(RE_CLEAN_VALUE, "$2");
|
|
2608
|
+
attrs$1[matchedKey] = buffer.slice(0, valueEnd).trim().replace(RE_CLEAN_VALUE, "$2");
|
|
2623
2609
|
buffer = buffer.slice(valueEnd);
|
|
2624
2610
|
}
|
|
2625
2611
|
return attrs$1;
|
|
@@ -2719,8 +2705,7 @@ const compiler = {
|
|
|
2719
2705
|
async function compileScript(source, type) {
|
|
2720
2706
|
const key = `${type}:::${source}`;
|
|
2721
2707
|
if (cache.has(key)) return cache.get(key);
|
|
2722
|
-
const
|
|
2723
|
-
const res = await transform(source, {
|
|
2708
|
+
const res = await (await compiler.script())(source, {
|
|
2724
2709
|
target: "es2018",
|
|
2725
2710
|
platform: "browser",
|
|
2726
2711
|
format: "cjs",
|
|
@@ -2735,20 +2720,17 @@ async function compileStyle(source, type) {
|
|
|
2735
2720
|
if (cache.has(key)) return cache.get(key);
|
|
2736
2721
|
if (type === "css") return source;
|
|
2737
2722
|
if (type === "less") {
|
|
2738
|
-
const
|
|
2739
|
-
const res = await less.render(source);
|
|
2723
|
+
const res = await (await compiler.less()).render(source);
|
|
2740
2724
|
cache.set(key, res.css);
|
|
2741
2725
|
return res.css;
|
|
2742
2726
|
}
|
|
2743
2727
|
if (type === "scss") {
|
|
2744
|
-
const
|
|
2745
|
-
const res = sass.compileString(source);
|
|
2728
|
+
const res = (await compiler.sass()).compileString(source);
|
|
2746
2729
|
cache.set(key, res.css);
|
|
2747
2730
|
return res.css;
|
|
2748
2731
|
}
|
|
2749
2732
|
if (type === "stylus") {
|
|
2750
|
-
const
|
|
2751
|
-
const res = stylus.render(source);
|
|
2733
|
+
const res = (await compiler.stylus()).render(source);
|
|
2752
2734
|
cache.set(key, res);
|
|
2753
2735
|
return res;
|
|
2754
2736
|
}
|
|
@@ -3257,8 +3239,7 @@ function getContainerMeta(info) {
|
|
|
3257
3239
|
//#endregion
|
|
3258
3240
|
//#region src/node/demo/extendPage.ts
|
|
3259
3241
|
function extendsPageWithDemo(page) {
|
|
3260
|
-
const
|
|
3261
|
-
const demoFiles = markdownEnv.demoFiles ?? [];
|
|
3242
|
+
const demoFiles = page.markdownEnv.demoFiles ?? [];
|
|
3262
3243
|
page.deps.push(...demoFiles.filter(({ type }) => type === "markdown").map(({ path: path$3 }) => path$3));
|
|
3263
3244
|
(page.frontmatter.gitInclude ??= []).push(...demoFiles.filter(({ gitignore }) => !gitignore).map(({ path: path$3 }) => path$3));
|
|
3264
3245
|
}
|
|
@@ -3811,8 +3792,7 @@ function linksPlugin(md) {
|
|
|
3811
3792
|
const hrefIndex = token.attrIndex("href");
|
|
3812
3793
|
/* istanbul ignore if -- @preserve */
|
|
3813
3794
|
if (hrefIndex < 0) return;
|
|
3814
|
-
const
|
|
3815
|
-
const hrefLink = hrefAttr[1];
|
|
3795
|
+
const hrefLink = token.attrs[hrefIndex][1];
|
|
3816
3796
|
if (isLinkWithProtocol(hrefLink)) {
|
|
3817
3797
|
Object.entries(externalAttrs).forEach(([key, val]) => {
|
|
3818
3798
|
token.attrSet(key, val);
|
|
@@ -4129,8 +4109,7 @@ const abbrPlugin = (md) => {
|
|
|
4129
4109
|
md.renderer.rules.abbreviation = (tokens, idx, _, env) => {
|
|
4130
4110
|
const { content, info } = tokens[idx];
|
|
4131
4111
|
const rendered = md.renderInline(info, cleanMarkdownEnv(env));
|
|
4132
|
-
|
|
4133
|
-
return `<Abbreviation aria-label="${label}">${content}${info ? `<template #tooltip>${rendered}</template>` : ""}</Abbreviation>`;
|
|
4112
|
+
return `<Abbreviation aria-label="${rendered.replace(/<[^>]*>/g, "")}">${content}${info ? `<template #tooltip>${rendered}</template>` : ""}</Abbreviation>`;
|
|
4134
4113
|
};
|
|
4135
4114
|
};
|
|
4136
4115
|
|
|
@@ -4161,11 +4140,10 @@ const annotationDef = (state, startLine, endLine, silent) => {
|
|
|
4161
4140
|
annotation += `\n${source}`;
|
|
4162
4141
|
nextLine++;
|
|
4163
4142
|
}
|
|
4164
|
-
|
|
4143
|
+
(data[`:${label}`] ??= {
|
|
4165
4144
|
sources: [],
|
|
4166
4145
|
rendered: []
|
|
4167
|
-
};
|
|
4168
|
-
current.sources.push(annotation);
|
|
4146
|
+
}).sources.push(annotation);
|
|
4169
4147
|
state.line = nextLine;
|
|
4170
4148
|
return true;
|
|
4171
4149
|
};
|
|
@@ -4182,8 +4160,7 @@ const annotationRef = (state, silent) => {
|
|
|
4182
4160
|
if (pos === start + 2 || pos >= max) return false;
|
|
4183
4161
|
pos++;
|
|
4184
4162
|
const label = state.src.slice(start + 2, pos - 1);
|
|
4185
|
-
|
|
4186
|
-
if (annotations.length === 0) return false;
|
|
4163
|
+
if ((state.env.annotations?.[`:${label}`]?.sources ?? []).length === 0) return false;
|
|
4187
4164
|
if (!silent) {
|
|
4188
4165
|
const refToken = state.push("annotation_ref", "", 0);
|
|
4189
4166
|
refToken.meta = { label };
|
|
@@ -4270,7 +4247,7 @@ function inlineSyntaxPlugin(md, options) {
|
|
|
4270
4247
|
* [HTML]: A HTML element description
|
|
4271
4248
|
*/
|
|
4272
4249
|
md.use(abbrPlugin);
|
|
4273
|
-
if (options.plot === true || isPlainObject(options.plot)
|
|
4250
|
+
if (options.plot === true || isPlainObject(options.plot)) md.use(plotPlugin);
|
|
4274
4251
|
}
|
|
4275
4252
|
|
|
4276
4253
|
//#endregion
|
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.164",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"lib"
|
|
32
32
|
],
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"artplayer": "^5.
|
|
34
|
+
"artplayer": "^5.3.0",
|
|
35
35
|
"dashjs": "^5.0.3",
|
|
36
|
-
"esbuild": "^0.25.
|
|
37
|
-
"hls.js": "^1.6.
|
|
36
|
+
"esbuild": "^0.25.10",
|
|
37
|
+
"hls.js": "^1.6.12",
|
|
38
38
|
"less": "^4.4.1",
|
|
39
39
|
"markdown-it": "^14.1.0",
|
|
40
40
|
"mpegts.js": "^1.7.3",
|
|
41
41
|
"pyodide": "^0.28.2",
|
|
42
|
-
"sass": "^1.
|
|
43
|
-
"sass-embedded": "^1.
|
|
42
|
+
"sass": "^1.93.0",
|
|
43
|
+
"sass-embedded": "^1.93.0",
|
|
44
44
|
"stylus": "^0.64.0",
|
|
45
45
|
"vuepress": "2.0.0-rc.24"
|
|
46
46
|
},
|
|
@@ -90,20 +90,20 @@
|
|
|
90
90
|
"chokidar": "4.0.3",
|
|
91
91
|
"image-size": "^2.0.2",
|
|
92
92
|
"local-pkg": "^1.1.2",
|
|
93
|
-
"lru-cache": "^11.1
|
|
93
|
+
"lru-cache": "^11.2.1",
|
|
94
94
|
"markdown-it-container": "^4.0.0",
|
|
95
95
|
"nanoid": "^5.1.5",
|
|
96
|
-
"shiki": "^3.
|
|
97
|
-
"tinyglobby": "0.2.13",
|
|
98
|
-
"tm-grammars": "^1.24.
|
|
96
|
+
"shiki": "^3.13.0",
|
|
97
|
+
"tinyglobby": "^0.2.13",
|
|
98
|
+
"tm-grammars": "^1.24.12",
|
|
99
99
|
"tm-themes": "^1.10.9",
|
|
100
100
|
"vue": "^3.5.21"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@types/markdown-it": "^14.1.2",
|
|
104
|
-
"artplayer": "^5.
|
|
104
|
+
"artplayer": "^5.3.0",
|
|
105
105
|
"dashjs": "^5.0.3",
|
|
106
|
-
"hls.js": "^1.6.
|
|
106
|
+
"hls.js": "^1.6.12",
|
|
107
107
|
"mpegts.js": "1.7.3"
|
|
108
108
|
},
|
|
109
109
|
"publishConfig": {
|