Skip to content

Commit c227828

Browse files
committed
【新增】添加代码高亮功能
- 将 markdown-html 版本从 1.11.1 升级到 1.12.0 - 添加 highlight.js 用于代码块语法高亮 - 在页面加载结束后触发代码高亮 - 引入 highlight.js 的默认样式表
1 parent d2e29f5 commit c227828

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22

33
<html>
4-
<markdown-html version="1.11.1" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
4+
<markdown-html version="1.12.0" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
55
license="CC BY-SA 4.0 International"></markdown-html>
66

77
<head>
@@ -15,9 +15,11 @@
1515
<script src="https://lib.baomitu.com/pjax/0.2.8/pjax.min.js" type="text/javascript"></script>
1616
<script src="https://lib.baomitu.com/translate.js/3.7.2/translate.js" type="text/javascript"></script>
1717
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/Darkmode.js/1.5.7/darkmode-js.min.js"
18-
type="text/javascript"></script>
18+
type="application/javascript"></script>
1919
<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-y/mermaid/8.14.0/mermaid.min.js"
20-
type="text/javascript"></script>
20+
type="application/javascript"></script>
21+
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-y/highlight.js/11.4.0/highlight.min.js"
22+
type="application/javascript"></script>
2123
<script>
2224
// 使用 IIFE 包裹以避免全局变量污染
2325
(function () {
@@ -605,6 +607,7 @@
605607
infoTranslate(); //// 检查并提示翻译
606608
await mermaid.init({ noteMargin: 10 }, '.language-mermaid'); //// 初始化 mermaid
607609
translate.execute(); //// 手动触发翻译,但是理论上 translate-js 会监听页面变化
610+
hljs.highlightAll(); //// 触发代码块语法高亮
608611
endLoad();
609612
window.scrollTo({
610613
top: 0,
@@ -939,6 +942,8 @@
939942
}
940943
}
941944
</style>
945+
<link href="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-y/highlight.js/11.4.0/styles/default.min.css"
946+
type="text/css" rel="stylesheet" />
942947
<link rel="stylesheet"
943948
href="https://chinese-fonts-cdn.deno.dev/packages/maple-mono-cn/dist/MapleMono-CN-Regular/result.css" />
944949
</head>

0 commit comments

Comments
 (0)