wujingjing
2025-05-07 c26a0c5e20dfdcc45b43315b50296e90e30995d8
src/components/chat/libs/markdown.ts
@@ -56,6 +56,16 @@
// 添加自定义样式
const style = document.createElement('style');
// 自定义段落渲染规则
md.renderer.rules.paragraph_open = (tokens, idx) => {
   return '<p class="inline-block">'; // 添加 inline-block 类来控制显示
};
// 自定义表格渲染规则
md.renderer.rules.table_open = (tokens, idx) => {
   return '<table class="markdown-table">';
};
style.textContent = `
   .code-markdown-it-block {
      margin: 1em 0;
@@ -141,6 +151,19 @@
   .copy-icon, .check-icon {
      fill: currentColor;
   }
   .markdown-table {
      border-collapse: collapse;
      width: 100%;
   }
   .markdown-table thead {
      background-color: #f2f2f2;
   }
   .markdown-table th,
   .markdown-table td {
      border: 1px solid #ebebeb;
      padding: 8px;
      text-align: center;
   }
`;
document.head.appendChild(style);
export { md };