@huyooo/vite-markdown 0.3.16 → 0.3.17
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/index.js +55 -5
- package/dist/package.json +7 -3
- package/package.json +7 -3
- package/LICENSE.md +0 -21
package/dist/index.js
CHANGED
|
@@ -5,6 +5,55 @@ import { full as emoji } from 'markdown-it-emoji';
|
|
|
5
5
|
import MarkdownItPrism from 'markdown-it-prism';
|
|
6
6
|
import MarkdownItTocDoneRight from 'markdown-it-toc-done-right';
|
|
7
7
|
import Markdown from 'unplugin-vue-markdown/vite';
|
|
8
|
+
/** 容器默认标题(与 VitePress 一致,可后续做配置) */
|
|
9
|
+
const DEFAULT_LABELS = {
|
|
10
|
+
info: '信息',
|
|
11
|
+
tip: '提示',
|
|
12
|
+
warning: '警告',
|
|
13
|
+
danger: '危险',
|
|
14
|
+
details: '详细信息',
|
|
15
|
+
};
|
|
16
|
+
/** 表格包装:宽表可横向滚动,并突破内容区内边距全宽显示(与 VitePress 等文档站一致) */
|
|
17
|
+
function tableWrapper(md) {
|
|
18
|
+
const renderer = md.renderer;
|
|
19
|
+
const defaultOpen = renderer.rules.table_open;
|
|
20
|
+
const defaultClose = renderer.rules.table_close;
|
|
21
|
+
const proxy = (tokens, idx, options, _env, self) => self.renderToken(tokens, idx, options);
|
|
22
|
+
const open = defaultOpen ?? proxy;
|
|
23
|
+
const close = defaultClose ?? proxy;
|
|
24
|
+
renderer.rules.table_open = (tokens, idx, options, env, self) => {
|
|
25
|
+
return ('<div data-table-wrapper="true" class="table-wrapper">' +
|
|
26
|
+
'<div class="table-wrapper-inner">' +
|
|
27
|
+
open(tokens, idx, options, env, self));
|
|
28
|
+
};
|
|
29
|
+
renderer.rules.table_close = (tokens, idx, options, env, self) => {
|
|
30
|
+
return close(tokens, idx, options, env, self) + '</div></div>';
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** 创建带自定义标题的容器(::: type 标题 或 ::: type);标题为 type 后的文案,无则用 defaultTitle */
|
|
34
|
+
function createContainer(md, klass, defaultTitle) {
|
|
35
|
+
return [
|
|
36
|
+
MarkdownItContainer,
|
|
37
|
+
klass,
|
|
38
|
+
{
|
|
39
|
+
render(tokens, idx) {
|
|
40
|
+
const token = tokens[idx];
|
|
41
|
+
if (token.nesting !== 1) {
|
|
42
|
+
return klass === 'details' ? `</details>\n` : `</div>\n`;
|
|
43
|
+
}
|
|
44
|
+
token.attrJoin('class', `${klass} custom-block`);
|
|
45
|
+
const attrs = md.renderer.renderAttrs(token);
|
|
46
|
+
const info = token.info.trim().slice(klass.length).trim();
|
|
47
|
+
const title = info ? md.utils.escapeHtml(info) : defaultTitle;
|
|
48
|
+
const titleClass = 'custom-block-title' + (info ? '' : ' custom-block-title-default');
|
|
49
|
+
if (klass === 'details') {
|
|
50
|
+
return `<details ${attrs}><summary class="${titleClass}">${title}</summary>\n`;
|
|
51
|
+
}
|
|
52
|
+
return `<div ${attrs}><p class="${titleClass}">${title}</p>\n`;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}
|
|
8
57
|
export function createMarkdownPlugin() {
|
|
9
58
|
return Markdown({
|
|
10
59
|
markdownItOptions: {
|
|
@@ -14,6 +63,7 @@ export function createMarkdownPlugin() {
|
|
|
14
63
|
},
|
|
15
64
|
markdownItSetup(md) {
|
|
16
65
|
md.use(MarkdownItAnchor);
|
|
66
|
+
md.use(tableWrapper);
|
|
17
67
|
md.use(MarkdownItPrism);
|
|
18
68
|
md.use(MarkdownItCopy, {
|
|
19
69
|
btnText: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M7 9.667A2.667 2.667 0 0 1 9.667 7h8.666A2.667 2.667 0 0 1 21 9.667v8.666A2.667 2.667 0 0 1 18.333 21H9.667A2.667 2.667 0 0 1 7 18.333z"/><path d="M4.012 16.737A2 2 0 0 1 3 15V5c0-1.1.9-2 2-2h10c.75 0 1.158.385 1.5 1"/></g></svg>',
|
|
@@ -23,16 +73,16 @@ export function createMarkdownPlugin() {
|
|
|
23
73
|
showCodeLanguage: true,
|
|
24
74
|
extraHtmlBeforeBtn: '',
|
|
25
75
|
});
|
|
26
|
-
md.use(
|
|
27
|
-
md.use(
|
|
28
|
-
md.use(
|
|
29
|
-
md.use(
|
|
76
|
+
md.use(...createContainer(md, 'tip', DEFAULT_LABELS.tip));
|
|
77
|
+
md.use(...createContainer(md, 'info', DEFAULT_LABELS.info));
|
|
78
|
+
md.use(...createContainer(md, 'warning', DEFAULT_LABELS.warning));
|
|
79
|
+
md.use(...createContainer(md, 'danger', DEFAULT_LABELS.danger));
|
|
80
|
+
md.use(...createContainer(md, 'details', DEFAULT_LABELS.details));
|
|
30
81
|
md.use(emoji);
|
|
31
82
|
md.use(MarkdownItTocDoneRight, {
|
|
32
83
|
level: [1, 2, 3],
|
|
33
84
|
containerClass: 'toc',
|
|
34
85
|
});
|
|
35
|
-
// 如需 details 容器可在此解开
|
|
36
86
|
},
|
|
37
87
|
wrapperClasses: 'markdown-body',
|
|
38
88
|
});
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huyooo/vite-markdown",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "MCP server for fetching and parsing Hacker News stories",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "rimraf dist && tsc && cp package.json dist/",
|
|
15
15
|
"watch": "tsc --watch",
|
|
16
|
-
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js"
|
|
16
|
+
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js",
|
|
17
|
+
"release": "bumpp && npm publish",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
21
|
"markdown-it-anchor": "^9.2.0",
|
|
@@ -21,10 +23,12 @@
|
|
|
21
23
|
"markdown-it-copy": "^1.2.0",
|
|
22
24
|
"markdown-it-emoji": "^3.0.0",
|
|
23
25
|
"markdown-it-prism": "^3.0.0",
|
|
26
|
+
"markdown-it-toc-done-right": "^4.2.0",
|
|
24
27
|
"typescript": "^5.5.3",
|
|
25
28
|
"unplugin-vue-markdown": "^28.3.1"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
31
|
+
"bumpp": "^10.2.0",
|
|
28
32
|
"@types/markdown-it-container": "^2.0.10",
|
|
29
33
|
"@types/markdown-it-emoji": "^3.0.1",
|
|
30
34
|
"@types/node": "^22.14.0",
|
|
@@ -43,4 +47,4 @@
|
|
|
43
47
|
},
|
|
44
48
|
"homepage": "https://github.com/pskill9/hn-server#readme",
|
|
45
49
|
"gitHead": "3b89c5f3e764bd2502a11e40fdb1a574d9ee508d"
|
|
46
|
-
}
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huyooo/vite-markdown",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "MCP server for fetching and parsing Hacker News stories",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "rimraf dist && tsc && cp package.json dist/",
|
|
15
15
|
"watch": "tsc --watch",
|
|
16
|
-
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js"
|
|
16
|
+
"inspector": "npx @modelcontextprotocol/inspector node dist/index.js",
|
|
17
|
+
"release": "bumpp && npm publish",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
21
|
"markdown-it-anchor": "^9.2.0",
|
|
@@ -21,10 +23,12 @@
|
|
|
21
23
|
"markdown-it-copy": "^1.2.0",
|
|
22
24
|
"markdown-it-emoji": "^3.0.0",
|
|
23
25
|
"markdown-it-prism": "^3.0.0",
|
|
26
|
+
"markdown-it-toc-done-right": "^4.2.0",
|
|
24
27
|
"typescript": "^5.5.3",
|
|
25
28
|
"unplugin-vue-markdown": "^28.3.1"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
31
|
+
"bumpp": "^10.2.0",
|
|
28
32
|
"@types/markdown-it-container": "^2.0.10",
|
|
29
33
|
"@types/markdown-it-emoji": "^3.0.1",
|
|
30
34
|
"@types/node": "^22.14.0",
|
|
@@ -42,5 +46,5 @@
|
|
|
42
46
|
"url": "https://github.com/pskill9/hn-server/issues"
|
|
43
47
|
},
|
|
44
48
|
"homepage": "https://github.com/pskill9/hn-server#readme",
|
|
45
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "3b89c5f3e764bd2502a11e40fdb1a574d9ee508d"
|
|
46
50
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 fuguoqiang
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|