Skip to content

Commit ebd2548

Browse files
committed
【修复】文档和页面压缩格式化问题
1 parent 82ac08c commit ebd2548

5 files changed

Lines changed: 62 additions & 57 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
### 注意事项
3030

31-
- 单次 Pull Request 不应提交过多修改,请确保每次提交都针对特定的功能且务必说明本次改动的具体目的,例如:修复某 bug 、优化某方法 等,方便进行 Code Review;
31+
- 单次 Pull Request 不应提交过多修改,请确保每次提交都针对特定的功能且务必说明本次改动的具体目的,例如:修复某 bug、优化某方法 等,方便进行 Code Review;
3232
- 对于 bug 的修复,应该将本次 Pull Request 和相对应 bug 的 issue 关联起来,让别人知道该问题已经被修复;
33-
- 对于较大的新功能,你需要先提交 Issues,例如 “【新增】添加 XXX 功能”,确认该功能有被添加的必要后,再开始工作;
33+
- 对于较大的新功能,你需要先提交 Issues,例如“【新增】添加 XXX 功能”,确认该功能有被添加的必要后,再开始工作;
3434
- 对于一些主观的样式、交互逻辑调整:如颜色、图标的使用,某些预设配置的增减修改等,一般不予通过。但可以在 Discussions 中进行讨论;
3535
- 其他如简单的代码优化、文档修正等,只要修改合理都会被接受。

doc/scripts.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 1. 引言
44

5-
本文档详细说明项目中三个 Bash 脚本(`get-version.bash`, `is-newer-version.bash`, `release.bash`)和主程序(`src/main.rs`)的设计与功能。这些组件协同工作,实现版本管理、发布流程和 HTML 处理功能。
5+
本文档详细说明项目中三个 Bash 脚本 (`get-version.bash`, `is-newer-version.bash`, `release.bash`) 和主程序 (`src/main.rs`) 的设计与功能。这些组件协同工作,实现版本管理、发布流程和 HTML 处理功能。
66

77
```mermaid
88
graph TD
@@ -22,9 +22,9 @@ graph TD
2222

2323
1. **路径解析**
2424

25-
- 自动检测脚本所在目录(`$SCRIPT_DIR`)
26-
- 计算仓库根目录(`$REPO_DIR`)
27-
- 支持自定义文件路径参数(`$1`)
25+
- 自动检测脚本所在目录 (`$SCRIPT_DIR`)
26+
- 计算仓库根目录 (`$REPO_DIR`)
27+
- 支持自定义文件路径参数 (`$1`)
2828

2929
2. **多语言支持**
3030

@@ -39,8 +39,8 @@ VERSION=$(grep -oP '<markdown-html\s+version="\K[^"]+' "$FILE_PATH" | head -1)
3939
```
4040

4141
4. **错误处理**
42-
- 文件不存在检测(`[ ! -f "$FILE_PATH" ]`)
43-
- 版本号缺失检测(`[ -z "$VERSION" ]`)
42+
- 文件不存在检测 (`[ ! -f "$FILE_PATH" ]`)
43+
- 版本号缺失检测 (`[ -z "$VERSION" ]`)
4444

4545
**使用示例**
4646

@@ -58,7 +58,7 @@ VERSION=$(grep -oP '<markdown-html\s+version="\K[^"]+' "$FILE_PATH" | head -1)
5858
1. **版本获取**
5959

6060
- 调用`get-version.bash`获取当前版本
61-
- 获取最新 Git 标签(`git tag -l 'v*'`)
61+
- 获取最新 Git 标签 (`git tag -l 'v*'`)
6262

6363
2. **版本比较算法**
6464

@@ -109,7 +109,7 @@ sequenceDiagram
109109
- 标签创建/推送失败
110110
4. **多语言界面**:所有交互提示支持中英文
111111

112-
## 3. 主程序分析(src/main.rs)
112+
## 3. 主程序分析 (src/main.rs)
113113

114114
HTML 处理核心程序,提供压缩和内联功能。
115115

doc/workflow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ graph LR
2222
工作流在以下事件触发:
2323

2424
- 推送到`master`分支
25-
- 手动触发(`workflow_dispatch`)
25+
- 手动触发 (`workflow_dispatch`)
2626

2727
## 3. 核心阶段详解
2828

@@ -81,7 +81,7 @@ sequenceDiagram
8181
- 设置 Rust 编译环境
8282
- 缓存依赖加速构建
8383
2. **项目构建**:
84-
- 发布模式编译(`cargo build --release`)
84+
- 发布模式编译 (`cargo build --release`)
8585
3. **HTML 生成**:
8686
- 执行主程序处理 index.html
8787
- 产出四种 HTML 变体

index.html

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22

33
<html>
44
<markdown-html
5-
version="1.20.8"
5+
version="1.20.9"
66
author="PJ568"
77
repo="https://github.com/PJ-568/markdown.html"
88
license="CC BY-SA 4.0 International"
9-
></markdown-html>
9+
>
10+
</markdown-html>
1011

1112
<head>
1213
<meta charset="utf-8" />
@@ -249,7 +250,7 @@
249250
bq.appendChild(switchButton);
250251

251252
const mainElement = document.querySelector(
252-
".markdown-body .content"
253+
".markdown-body .content",
253254
);
254255
mainElement.insertBefore(bq, mainElement.children[1]);
255256
}
@@ -353,17 +354,16 @@
353354
// 处理错误
354355
function updateContent(article, title = null, mdPath = pValue) {
355356
try {
356-
document.querySelector(
357-
".markdown-body"
358-
).innerHTML = `<div class="old-content Animated Animated-remove Animated--reverse Animate--fast Animate--noDelay Animate--slideInLeft">${
359-
document.querySelector(".markdown-body .content").innerHTML
360-
}</div><div class="content Animated Animate--slideInRight">${article}</div>`;
357+
document.querySelector(".markdown-body").innerHTML =
358+
`<div class="old-content Animated Animated-remove Animated--reverse Animate--fast Animate--noDelay Animate--slideInLeft">${
359+
document.querySelector(".markdown-body .content").innerHTML
360+
}</div><div class="content Animated Animate--slideInRight">${article}</div>`;
361361
firstH1 = document.querySelector(".markdown-body .content h1");
362362
document.title = title
363363
? title
364364
: firstH1
365-
? firstH1.textContent
366-
: mdPath;
365+
? firstH1.textContent
366+
: mdPath;
367367
} catch (error) {
368368
throw error;
369369
}
@@ -374,7 +374,7 @@
374374
return new Promise((resolve, reject) => {
375375
//// 检查是否已加载
376376
const existingLinks = document.querySelectorAll(
377-
`link[href="${url}"]`
377+
`link[href="${url}"]`,
378378
);
379379
if (existingLinks.length > 0) {
380380
return resolve(url);
@@ -398,7 +398,7 @@
398398
link.onerror = null;
399399
link.onload = null;
400400
document.head.removeChild(link);
401-
reject(new Error(`无法加载CSS文件: ${url}`));
401+
reject(new Error(`无法加载 CSS 文件:${url}`));
402402
};
403403

404404
//// 添加到文档头部
@@ -422,7 +422,7 @@
422422
if (completedCount === totalElements) {
423423
parentElement.removeEventListener(
424424
"animationend",
425-
handleAnimationEnd
425+
handleAnimationEnd,
426426
);
427427
resolve();
428428
}
@@ -437,17 +437,17 @@
437437
function handleError(mdPath, errorMessage) {
438438
updateContent(
439439
`<h1>加载失败</h1><p>加载文档<code>${mdPath}</code>时出错:<code>${errorMessage}</code>。您可以尝试<a class="refresh-btn" href="">重新加载</a>或<a class="back-btn">返回</a>。</p>`,
440-
"加载失败"
440+
"加载失败",
441441
);
442442
waitForAnimationsEnd(
443443
document.querySelector(".markdown-body"),
444444
".content, .old-content",
445-
["Animation-slideInRight", "Animation-slideInLeft"]
445+
["Animation-slideInRight", "Animation-slideInLeft"],
446446
).then(() => {
447447
customPushState(
448448
window.location.origin +
449449
window.location.pathname +
450-
(mdPath ? "?p=" + mdPath : "")
450+
(mdPath ? "?p=" + mdPath : ""),
451451
);
452452
});
453453
endLoad();
@@ -517,13 +517,13 @@
517517
waitForAnimationsEnd(
518518
document.querySelector(".markdown-body"),
519519
".content, .old-content",
520-
["Animation-slideInRight", "Animation-slideInLeft"]
520+
["Animation-slideInRight", "Animation-slideInLeft"],
521521
).then(async () => {
522522
await showMarkdownEnded();
523523
customPushState(
524524
window.location.origin +
525525
window.location.pathname +
526-
(mdPath ? "?p=" + mdPath : "")
526+
(mdPath ? "?p=" + mdPath : ""),
527527
);
528528
});
529529
} catch (error) {
@@ -536,7 +536,7 @@
536536
//// 生成目录
537537
function generateOutline(doc) {
538538
const headings = Array.from(
539-
doc.querySelectorAll("h1, h2, h3, h4, h5, h6")
539+
doc.querySelectorAll("h1, h2, h3, h4, h5, h6"),
540540
);
541541
if (headings.length === 0) return "<i>无目录</i>";
542542
var outline = "<ul>";
@@ -593,7 +593,7 @@
593593
"," +
594594
response.status +
595595
"," +
596-
response.statusText
596+
response.statusText,
597597
);
598598
}
599599
}
@@ -608,7 +608,7 @@
608608
const linkParser = new DOMParser();
609609
const linkDoc = linkParser.parseFromString(
610610
`<div>${content}</div>`,
611-
"text/html"
611+
"text/html",
612612
);
613613

614614
//// 处理所有 a 链接
@@ -659,7 +659,7 @@
659659

660660
//// 添加目录
661661
content = `<details class="outline"><summary>${decodeURIComponent(
662-
mdPath
662+
mdPath,
663663
)}</summary></details><hr>${content}`;
664664
const parser = new DOMParser();
665665
const doc = parser.parseFromString(content, "text/html");
@@ -678,11 +678,11 @@
678678
responseText,
679679
request,
680680
href,
681-
options
681+
options,
682682
) {
683683
if (
684684
/^<!doctype html>[\s\S]*?<html>[\s\S]*?<markdown-html/i.test(
685-
request.responseText
685+
request.responseText,
686686
)
687687
) {
688688
await showMarkdown(await decodeMDPath(href));
@@ -720,7 +720,7 @@
720720
history.pushState(
721721
{ url: url, title: document.title, uid: level },
722722
null,
723-
url
723+
url,
724724
);
725725
lastLevel = level++;
726726
} else {
@@ -748,7 +748,7 @@
748748
function initAboutBtn() {
749749
const aboutBtn = document.querySelector(".about-btn");
750750
aboutBtn.href = `?p=${getDirectory(
751-
window.location.pathname
751+
window.location.pathname,
752752
)}about.md`;
753753
}
754754

@@ -796,7 +796,7 @@
796796
} else if (event.animationName === "Animation-slideInLeft") {
797797
document.querySelector(".markdown-body .old-content").remove();
798798
}
799-
}
799+
},
800800
);
801801
//// 点击事件委托
802802
document.addEventListener("click", function (event) {
@@ -894,8 +894,9 @@
894894
textarea,
895895
code,
896896
pre {
897-
font-family: "Sarasa Term SC Nerd", "Maple Mono CN", Ubuntu, Roboto,
898-
"Open Sans", "Microsoft YaHei", Arial, sans-serif;
897+
font-family:
898+
"Sarasa Term SC Nerd", "Maple Mono CN", Ubuntu, Roboto, "Open Sans",
899+
"Microsoft YaHei", Arial, sans-serif;
899900
text-decoration: none;
900901
}
901902

@@ -950,7 +951,9 @@
950951
nav a {
951952
color: #fafafa;
952953
padding: 0.3rem;
953-
transition: color 0.2s, background-color 0.2s;
954+
transition:
955+
color 0.2s,
956+
background-color 0.2s;
954957
}
955958

956959
nav a:hover {
@@ -1041,7 +1044,9 @@
10411044

10421045
/* Markdown 样式 */
10431046
.markdown-body a {
1044-
transition: color 0.2s, background-color 0.2s;
1047+
transition:
1048+
color 0.2s,
1049+
background-color 0.2s;
10451050
}
10461051

10471052
.markdown-body a:hover {
@@ -1225,7 +1230,7 @@
12251230
<!-- 导航栏 -->
12261231
<nav>
12271232
<a title="返回" class="back-btn">
1228-
<license content="Copyright (c) 2018-2025 Tabler" />
1233+
<license content="Copyright (c) 2018-2025 Tabler"></license>
12291234
<svg
12301235
xmlns="http://www.w3.org/2000/svg"
12311236
width="24"
@@ -1243,7 +1248,7 @@
12431248
</svg>
12441249
</a>
12451250
<a title="刷新" class="refresh-btn" href="">
1246-
<license content="Copyright (c) 2018-2025 Tabler" />
1251+
<license content="Copyright (c) 2018-2025 Tabler"></license>
12471252
<svg
12481253
xmlns="http://www.w3.org/2000/svg"
12491254
width="24"
@@ -1262,7 +1267,7 @@
12621267
</svg>
12631268
</a>
12641269
<a title="主页" class="to-home">
1265-
<license content="Copyright (c) 2018-2025 Tabler" />
1270+
<license content="Copyright (c) 2018-2025 Tabler"></license>
12661271
<svg
12671272
xmlns="http://www.w3.org/2000/svg"
12681273
width="24"
@@ -1282,7 +1287,7 @@
12821287
</svg>
12831288
</a>
12841289
<a title="更改语言" id="translate">
1285-
<license content="Copyright (c) 2018-2025 Tabler" />
1290+
<license content="Copyright (c) 2018-2025 Tabler"></license>
12861291
<svg
12871292
xmlns="http://www.w3.org/2000/svg"
12881293
width="24"
@@ -1304,7 +1309,7 @@
13041309
</svg>
13051310
</a>
13061311
<a title="切换显示模式" class="dark-btn" href="javascript:;">
1307-
<license content="Copyright (c) 2018-2025 Tabler" />
1312+
<license content="Copyright (c) 2018-2025 Tabler"></license>
13081313
<svg
13091314
xmlns="http://www.w3.org/2000/svg"
13101315
width="24"
@@ -1326,7 +1331,7 @@
13261331
</svg>
13271332
</a>
13281333
<a title="关于" class="about-btn">
1329-
<license content="Copyright (c) 2018-2025 Tabler" />
1334+
<license content="Copyright (c) 2018-2025 Tabler"></license>
13301335
<svg
13311336
xmlns="http://www.w3.org/2000/svg"
13321337
width="24"

0 commit comments

Comments
 (0)