wujingjing
2024-11-15 a7685b93de4f623e91fce94b4e5f419ca3015c55
src/components/chat/libs/markdown.ts
@@ -1,4 +1,4 @@
import highlight from 'highlight.js';
// import highlight from 'highlight.js';
import Markdown from 'markdown-it';
const mdOptions: Markdown.Options = {
@@ -7,15 +7,16 @@
   breaks: true,
   langPrefix: 'language-',
   // 代码高亮
   highlight(str, lang) {
      if (lang && highlight.getLanguage(lang)) {
         try {
            return '<pre class="hljs"><code>' + highlight.highlight(lang, str, true).value + '</code></pre>';
         } catch (__) {
      }
      }
      return '';
   },
   // hightlight 加载过慢
   // highlight(str, lang) {
   //    if (lang && highlight.getLanguage(lang)) {
   //       try {
   //          return '<pre class="hljs"><code>' + highlight.highlight(lang, str, true).value + '</code></pre>';
   //       } catch (__) {
    //   }
   //    }
   //    return '';
   // },
};
export const md = new Markdown(mdOptions);