md2wechat-mcp 0.2.0 → 0.2.1
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/README.md +304 -5
- package/dist/browser.js +2 -0
- package/dist/cache.js +4 -3
- package/dist/cli.js +10 -1
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +11 -7
- package/dist/server.js +73 -9
- package/dist/themes.d.ts +2 -0
- package/dist/themes.js +41 -15
- package/dist/tools.js +577 -15
- package/dist/wechat-api.d.ts +10 -0
- package/dist/wechat-api.js +51 -1
- package/package.json +1 -1
package/dist/themes.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const THEMES = {
|
|
2
2
|
default: {
|
|
3
3
|
article: "max-width: 860px; margin: 0 auto; color: #1f2329; font-size: 16px; line-height: 1.8;",
|
|
4
|
-
h1: "font-size:
|
|
5
|
-
h2: "font-size:
|
|
6
|
-
h3: "font-size:
|
|
4
|
+
h1: "font-size: 26px; line-height: 1.35; margin: 1.3em 0 0.7em; color: #102a43;",
|
|
5
|
+
h2: "font-size: 21px; line-height: 1.4; margin: 1.2em 0 0.65em; color: #16324f; border-left: 4px solid #1f6feb; padding-left: 10px;",
|
|
6
|
+
h3: "font-size: 18px; line-height: 1.45; margin: 1.1em 0 0.55em; color: #1f4b7a;",
|
|
7
7
|
p: "margin: 0.85em 0;",
|
|
8
8
|
li: "margin: 0.35em 0;",
|
|
9
9
|
blockquote: "margin: 1em 0; padding: 0.8em 1em; color: #35495e; background: #f4f8ff; border-left: 4px solid #81a8d8;",
|
|
@@ -21,9 +21,9 @@ export const THEMES = {
|
|
|
21
21
|
},
|
|
22
22
|
tech: {
|
|
23
23
|
article: "max-width: 860px; margin: 0 auto; color: #0f172a; font-size: 16px; line-height: 1.8;",
|
|
24
|
-
h1: "font-size:
|
|
25
|
-
h2: "font-size:
|
|
26
|
-
h3: "font-size:
|
|
24
|
+
h1: "font-size: 26px; line-height: 1.35; margin: 1.25em 0 0.68em; color: #111827;",
|
|
25
|
+
h2: "font-size: 21px; line-height: 1.4; margin: 1.2em 0 0.62em; color: #111827; border-bottom: 2px solid #0ea5e9; padding-bottom: 4px;",
|
|
26
|
+
h3: "font-size: 18px; line-height: 1.45; margin: 1.1em 0 0.52em; color: #0f172a;",
|
|
27
27
|
p: "margin: 0.82em 0;",
|
|
28
28
|
li: "margin: 0.32em 0;",
|
|
29
29
|
blockquote: "margin: 1em 0; padding: 0.8em 1em; color: #0f172a; background: #f8fafc; border-left: 4px solid #38bdf8;",
|
|
@@ -41,9 +41,9 @@ export const THEMES = {
|
|
|
41
41
|
},
|
|
42
42
|
warm: {
|
|
43
43
|
article: "max-width: 860px; margin: 0 auto; color: #3b2f2f; font-size: 16px; line-height: 1.82;",
|
|
44
|
-
h1: "font-size:
|
|
45
|
-
h2: "font-size:
|
|
46
|
-
h3: "font-size:
|
|
44
|
+
h1: "font-size: 26px; line-height: 1.35; margin: 1.3em 0 0.7em; color: #5f2d1b;",
|
|
45
|
+
h2: "font-size: 21px; line-height: 1.42; margin: 1.2em 0 0.64em; color: #7a3118; border-left: 4px solid #d97706; padding-left: 10px;",
|
|
46
|
+
h3: "font-size: 18px; line-height: 1.46; margin: 1.1em 0 0.55em; color: #8a3d1f;",
|
|
47
47
|
p: "margin: 0.86em 0;",
|
|
48
48
|
li: "margin: 0.36em 0;",
|
|
49
49
|
blockquote: "margin: 1em 0; padding: 0.8em 1em; color: #5c4033; background: #fff8ef; border-left: 4px solid #f59e0b;",
|
|
@@ -61,9 +61,9 @@ export const THEMES = {
|
|
|
61
61
|
},
|
|
62
62
|
apple: {
|
|
63
63
|
article: "max-width: 820px; margin: 0 auto; color: #1d1d1f; font-size: 17px; line-height: 1.82; letter-spacing: 0.01em;",
|
|
64
|
-
h1: "font-size:
|
|
65
|
-
h2: "font-size:
|
|
66
|
-
h3: "font-size:
|
|
64
|
+
h1: "font-size: 30px; line-height: 1.28; margin: 1.35em 0 0.72em; color: #1d1d1f; font-weight: 700;",
|
|
65
|
+
h2: "font-size: 24px; line-height: 1.35; margin: 1.25em 0 0.66em; color: #1d1d1f; font-weight: 650;",
|
|
66
|
+
h3: "font-size: 20px; line-height: 1.42; margin: 1.15em 0 0.58em; color: #2c2c2e; font-weight: 600;",
|
|
67
67
|
p: "margin: 0.95em 0;",
|
|
68
68
|
li: "margin: 0.42em 0;",
|
|
69
69
|
blockquote: "margin: 1.05em 0; padding: 0.9em 1.05em; color: #3a3a3c; background: #f5f5f7; border-left: 3px solid #d2d2d7; border-radius: 8px;",
|
|
@@ -81,9 +81,9 @@ export const THEMES = {
|
|
|
81
81
|
},
|
|
82
82
|
"wechat-native": {
|
|
83
83
|
article: "max-width: 680px; margin: 0 auto; width: 100%; box-sizing: border-box; background-color: #ffffff; border-radius: 12px; padding: 16px; color: #333333; font-size: 15px; line-height: 1.75; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;",
|
|
84
|
-
h1: "display: block; font-size:
|
|
85
|
-
h2: "display: block; font-size:
|
|
86
|
-
h3: "display: block; font-size:
|
|
84
|
+
h1: "display: block; font-size: 24px; font-weight: 700; color: #163325; line-height: 1.32; margin: 36px 0 16px; letter-spacing: -0.015em; padding: 12px 16px 10px; background: linear-gradient(180deg, rgba(7,193,96,0.08) 0%, rgba(7,193,96,0.03) 100%); border-left: 5px solid #07c160; border-bottom: 1px dashed rgba(22,51,37,0.2); border-radius: 12px; box-shadow: 0 6px 14px rgba(7,193,96,0.05);",
|
|
85
|
+
h2: "display: block; font-size: 20px; font-weight: 700; color: #067647; line-height: 1.4; margin: 34px 0 18px; padding: 10px 14px; background: linear-gradient(90deg, rgba(7,193,96,0.12) 0%, rgba(7,193,96,0.03) 70%, rgba(7,193,96,0) 100%); border-left: 4px solid #07c160; border-radius: 12px;",
|
|
86
|
+
h3: "display: block; font-size: 18px; font-weight: 700; color: #0a6c44; line-height: 1.42; margin: 28px 0 14px; padding-left: 10px; border-left: 3px solid rgba(7,193,96,0.5);",
|
|
87
87
|
p: "margin: 18px 0; line-height: 1.75; color: #333333;",
|
|
88
88
|
li: "margin: 0.36em 0; color: #333333;",
|
|
89
89
|
blockquote: "margin: 1.1em 0; padding: 0.85em 1em; color: #214737; background: #f3fbf7; border-left: 4px solid #07c160; border-radius: 8px;",
|
|
@@ -101,3 +101,29 @@ export const THEMES = {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
export const THEME_NAMES = Object.keys(THEMES);
|
|
104
|
+
const FONT_SIZE_FACTORS = {
|
|
105
|
+
small: 0.9,
|
|
106
|
+
medium: 1,
|
|
107
|
+
large: 1.1
|
|
108
|
+
};
|
|
109
|
+
function formatScaledNumber(value) {
|
|
110
|
+
const rounded = Math.round(value * 1000) / 1000;
|
|
111
|
+
return Number.isInteger(rounded) ? String(rounded) : String(rounded).replace(/\.?0+$/u, "");
|
|
112
|
+
}
|
|
113
|
+
function scaleFontSizeInStyle(style, factor) {
|
|
114
|
+
return style.replace(/font-size:\s*([0-9]*\.?[0-9]+)(px|em|rem)/giu, (_match, numText, unit) => {
|
|
115
|
+
const num = Number(numText);
|
|
116
|
+
if (!Number.isFinite(num)) {
|
|
117
|
+
return `font-size: ${numText}${unit}`;
|
|
118
|
+
}
|
|
119
|
+
return `font-size: ${formatScaledNumber(num * factor)}${unit}`;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export function resolveTheme(themeName, fontSizePreset = "medium") {
|
|
123
|
+
const base = THEMES[themeName] ?? THEMES.default;
|
|
124
|
+
const factor = FONT_SIZE_FACTORS[fontSizePreset] ?? 1;
|
|
125
|
+
if (factor === 1) {
|
|
126
|
+
return base;
|
|
127
|
+
}
|
|
128
|
+
return Object.fromEntries(Object.entries(base).map(([key, value]) => [key, scaleFontSizeInStyle(value, factor)]));
|
|
129
|
+
}
|