vitepress-plugin-file-tree 0.5.0 → 0.7.0
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/node/index.js +4 -3
- package/package.json +3 -3
package/dist/node/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function fileTreeToCMDText(nodes, prefix = "") {
|
|
|
53
53
|
* A filename wrapped in double asterisks is highlighted as a focused node.
|
|
54
54
|
* The marker may be followed by a space and an inline comment.
|
|
55
55
|
*/
|
|
56
|
-
const RE_FOCUS = /^\*\*(
|
|
56
|
+
const RE_FOCUS = /^\*\*(.*?)\*\*(?:$|\s+)/;
|
|
57
57
|
/**
|
|
58
58
|
* Parse a single node info string, extracting filename, comment, type, and
|
|
59
59
|
* other metadata.
|
|
@@ -154,11 +154,12 @@ function parseContentWithContainer(content) {
|
|
|
154
154
|
};
|
|
155
155
|
const stack = [root];
|
|
156
156
|
const lines = content.trimEnd().split("\n");
|
|
157
|
+
/* v8 ignore next */
|
|
157
158
|
const spaceLength = lines[0]?.match(/^\s*/)?.[0].length ?? 0;
|
|
158
159
|
for (const line of lines) {
|
|
159
160
|
const match = line.match(/^(\s*)-(.*)$/);
|
|
160
161
|
if (!match) continue;
|
|
161
|
-
const level = Math.floor((match[1].length - spaceLength) / 2);
|
|
162
|
+
const level = Math.max(0, Math.floor((match[1].length - spaceLength) / 2));
|
|
162
163
|
const info = match[2].trim();
|
|
163
164
|
while (stack.length > 0 && stack[stack.length - 1].level >= level) stack.pop();
|
|
164
165
|
const parent = stack[stack.length - 1];
|
|
@@ -300,7 +301,7 @@ const fileTreeMarkdownPlugin = (md) => {
|
|
|
300
301
|
type: "file"
|
|
301
302
|
});
|
|
302
303
|
const nodeType = children.length > 0 ? "folder" : type;
|
|
303
|
-
const renderedComment = comment ? `<template #comment>${md.renderInline(comment
|
|
304
|
+
const renderedComment = comment ? `<template #comment>${md.renderInline(comment)}</template>` : "";
|
|
304
305
|
return `<VPFileTreeNode${stringifyAttrs({
|
|
305
306
|
expanded: nodeType === "folder" ? expanded : false,
|
|
306
307
|
focus,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-file-tree",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "Render file tree structure in your VitePress site.",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@pengzhanbo/utils": "^3.7.3",
|
|
41
41
|
"@vueuse/core": "^14.3.0",
|
|
42
|
-
"vitepress-plugin-toolkit": "0.
|
|
43
|
-
"vitepress-tuck": "0.
|
|
42
|
+
"vitepress-plugin-toolkit": "0.7.0",
|
|
43
|
+
"vitepress-tuck": "0.7.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public",
|