fix: mdRender 表格 HTML 用占位符保护,避免被 mdInline 转义为文本
这个提交包含在:
+10
-4
@@ -544,7 +544,8 @@ function mdInline(s){
|
||||
.replace(/`([^`]+)`/g,'<code style="background:#eef0f4;padding:1px 5px;border-radius:3px;font-family:var(--mono);font-size:12px">$1</code>');
|
||||
}
|
||||
function mdRender(md){
|
||||
// 1) Markdown 表格块 → <table class="mdtable">
|
||||
// 1) Markdown 表格块 → <table class="mdtable">(先替换为占位符,避免后续转义破坏)
|
||||
var tbls=[];
|
||||
md = md.replace(/(?:^|\n)\|?[^\n]*\|(?:\n|$)(?:\|?[^\n]*\|(?:\n|$))+/g, function(block){
|
||||
var lines=block.split('\n').filter(function(l){return l.trim();});
|
||||
var rows=[];
|
||||
@@ -556,12 +557,17 @@ function mdRender(md){
|
||||
if(!rows.length) return '';
|
||||
var h='<table class="mdtable"><tr>'+rows[0].map(function(c){return '<th>'+mdInline(c)+'</th>';}).join('')+'</tr>';
|
||||
for(var r=1;r<rows.length;r++) h+='<tr>'+rows[r].map(function(c){return '<td>'+mdInline(c)+'</td>';}).join('')+'</tr>';
|
||||
return h+'</table>';
|
||||
h+='</table>';
|
||||
tbls.push(h);
|
||||
return '\u0000TBL'+(tbls.length-1)+'\u0000';
|
||||
});
|
||||
// 2) 行内 + 引用 + 空行(表格已无裸换行,不受影响)
|
||||
// 2) 行内 + 引用 + 空行
|
||||
var esc=mdInline(md);
|
||||
esc=esc.replace(/^> (.+)$/gm,'<div style="border-left:3px solid var(--blue);background:var(--blue-bg);padding:6px 10px;border-radius:0 6px 6px 0;margin:6px 0;color:#3a5a78">$1</div>');
|
||||
return esc.replace(/\n{2,}/g,'<br>');
|
||||
esc=esc.replace(/\n{2,}/g,'<br>');
|
||||
// 3) 还原表格
|
||||
for(var i=0;i<tbls.length;i++) esc=esc.replace('\u0000TBL'+i+'\u0000', tbls[i]);
|
||||
return esc;
|
||||
}
|
||||
function addMsg(role,html){
|
||||
var flow=document.getElementById('chatFlow');
|
||||
|
||||
在新工单中引用
屏蔽一个用户