mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-05-01 05:33:24 +08:00
feat: 测试markdown
This commit is contained in:
17
Yi.Ai.Vue3/src/vue-element-plus-y/hooks/usePrism.ts
Normal file
17
Yi.Ai.Vue3/src/vue-element-plus-y/hooks/usePrism.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import Prism from 'prismjs';
|
||||
|
||||
export function usePrism() {
|
||||
const highlight = (code: string, lang: string) => {
|
||||
try {
|
||||
const grammar = Prism.languages[lang];
|
||||
if (grammar) {
|
||||
return Prism.highlight(code, grammar, lang);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
catch {
|
||||
return code;
|
||||
}
|
||||
};
|
||||
return highlight;
|
||||
}
|
||||
Reference in New Issue
Block a user