Skip to content

Commit ce5e68f

Browse files
committed
update PostDetailView to support Latex math format
1 parent 4c6cc70 commit ce5e68f

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

client/package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"bytemd": "^1.22.0",
1818
"highlight.js": "^11.11.1",
1919
"markdown-it": "^14.1.0",
20+
"markdown-it-katex": "^2.0.3",
2021
"vue": "^3.5.13",
2122
"vue-router": "^4.5.0"
2223
},

client/src/views/PostDetailView.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ import Footer from '../components/Footer.vue';
7878
import CommentSection from '../components/CommentSection.vue';
7979
import api from '../api';
8080
import MarkdownIt from 'markdown-it';
81+
import markdownItKatex from 'markdown-it-katex';
82+
import 'katex/dist/katex.css';
8183
// 引入 highlight.js 样式 (建议在 main.js 全局引入,不过这里保留以防万一)
8284
import 'highlight.js/styles/atom-one-dark.css';
8385
@@ -96,6 +98,8 @@ const md = new MarkdownIt({
9698
}
9799
});
98100
101+
md.use(markdownItKatex);
102+
99103
const post = ref(null);
100104
const loading = ref(true);
101105
const route = useRoute();

0 commit comments

Comments
 (0)