0.4.0-pre.14

This is a special version (since the repository hasn't been updated for a while). It includes partial updates from 0.3 to 0.4, along with several fixes for 0.4.0-pre.13.

这是一个特殊版本(因为一段时间没有更新存储库),它包含0.3至0.4的部分更新以及对0.4.0-pre.13的几处修复。
This commit is contained in:
wisdgod
2025-12-23 11:18:28 +08:00
parent 280c2d71a8
commit 65a390d4f2
428 changed files with 66005 additions and 15324 deletions

View File

@@ -27,35 +27,15 @@ const cssOptions = {
level: 2
};
// 处理文件
async function minifyFile(inputPath, outputPath) {
try {
let ext = path.extname(inputPath).toLowerCase();
if (ext === '.md') ext = '.html';
const filename = path.basename(inputPath);
let content = fs.readFileSync(inputPath, 'utf8');
let minified;
// 特殊处理 readme.html
if (filename.toLowerCase() === 'readme.md') {
const md = new MarkdownIt({
html: true,
linkify: true,
typographer: true
}).use(MarkdownItAnchor, {
// 可选自定义slug生成函数
slugify: (s) => String(s).trim().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\u4e00-\u9fa5\-]/g, '')
});
const readmeMdPath = path.join(__dirname, '..', 'README.md');
const markdownContent = fs.readFileSync(readmeMdPath, 'utf8');
// 添加基本的 markdown 样式
const htmlContent = `
// 生成 Markdown HTML 模板
function generateMarkdownHtml(title, markdownContent, md) {
return `
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>README</title>
<title>${title}</title>
<style>
:root {
--bg-color: #ffffff;
@@ -90,8 +70,12 @@ async function minifyFile(inputPath, outputPath) {
}
code {
background-color: var(--code-bg);
padding: 2px 4px;
border-radius: 3px;
}
pre code {
padding: 0;
}
img {
max-width: 100%;
}
@@ -133,8 +117,40 @@ async function minifyFile(inputPath, outputPath) {
${md.render(markdownContent)}
</body>
</html>
`;
content = htmlContent;
`;
}
// 处理文件
async function minifyFile(inputPath, outputPath) {
try {
let ext = path.extname(inputPath).toLowerCase();
const filename = path.basename(inputPath);
let content = fs.readFileSync(inputPath, 'utf8');
let minified;
// 处理 Markdown 文件
if (ext === '.md') {
const md = new MarkdownIt({
html: true,
linkify: true,
typographer: true
}).use(MarkdownItAnchor, {
slugify: (s) => String(s).trim().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\u4e00-\u9fa5\-]/g, '')
});
// 根据文件名确定标题
const baseName = path.basename(inputPath, '.md');
const title = baseName.charAt(0).toUpperCase() + baseName.slice(1).toLowerCase();
// 读取 Markdown 内容
const markdownPath = inputPath.toLowerCase().endsWith('.md')
? inputPath
: path.join(__dirname, '..', baseName + '.md');
const markdownContent = fs.readFileSync(markdownPath, 'utf8');
// 生成 HTML
content = generateMarkdownHtml(title, markdownContent, md);
ext = '.html';
}
switch (ext) {
@@ -187,14 +203,16 @@ async function main() {
const staticDir = path.join(__dirname, '..', 'static');
for (const file of files) {
// 特殊处理 README.md 的输入路径
let inputPath;
let outputPath;
if (file.toLowerCase() === 'readme.md') {
inputPath = path.join(__dirname, '..', 'README.md');
outputPath = path.join(staticDir, 'readme.min.html');
// 处理 Markdown 文件
if (file.toLowerCase().endsWith('.md')) {
const baseName = path.basename(file, '.md').toLowerCase();
inputPath = path.join(__dirname, '..', file);
outputPath = path.join(staticDir, `${baseName}.min.html`);
} else {
// 处理其他静态文件
inputPath = path.join(staticDir, file);
const ext = path.extname(file);
outputPath = path.join(

View File

@@ -19,9 +19,9 @@
}
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.12",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.12.tgz",
"integrity": "sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==",
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.0",
@@ -38,9 +38,9 @@
}
},
"node_modules/@jridgewell/source-map": {
"version": "0.3.10",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.10.tgz",
"integrity": "sha512-0pPkgz9dY+bijgistcTTJ5mR+ocqRXLuhXHYdzoMmmoJ2C9S46RCm2GMUbatPEUK9Yjy26IrAy8D/M00lLkv+Q==",
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
"license": "MIT",
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
@@ -48,15 +48,15 @@
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz",
"integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==",
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.29",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.29.tgz",
"integrity": "sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==",
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
@@ -305,13 +305,13 @@
}
},
"node_modules/terser": {
"version": "5.43.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.43.1.tgz",
"integrity": "sha512-+6erLbBm0+LROX2sPXlUYx/ux5PyE9K/a92Wrt6oA+WDAoFTdpHE5tCYCI5PNzq2y8df4rA+QgHLJuR4jNymsg==",
"version": "5.44.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.44.1.tgz",
"integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==",
"license": "BSD-2-Clause",
"dependencies": {
"@jridgewell/source-map": "^0.3.3",
"acorn": "^8.14.0",
"acorn": "^8.15.0",
"commander": "^2.20.0",
"source-map-support": "~0.5.20"
},