wujingjing
2024-11-18 0dae04f930427a728cecffa585884713755fac24
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,15 @@
   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 '';
   },
   // 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);