fix(M7.3): mdRender 块顺序——标题/列表在空行替换前处理,避免 \n\n→<br> 破坏行结构
这个提交包含在:
+6
-4
@@ -1129,23 +1129,25 @@ function mdRender(md){
|
|||||||
tbls.push(h);
|
tbls.push(h);
|
||||||
return '\u0000TBL'+(tbls.length-1)+'\u0000';
|
return '\u0000TBL'+(tbls.length-1)+'\u0000';
|
||||||
});
|
});
|
||||||
// 2) 行内 + 引用 + 空行
|
// 2) 行内 + 引用 + 标题 + 列表(块结构处理须在空行替换之前,避免 \n\n→<br> 破坏行结构)
|
||||||
var esc=mdInline(md);
|
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>');
|
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>');
|
||||||
esc=esc.replace(/\n{2,}/g,'<br>');
|
// 标题(一级→h3 二级→h4 三级→h5,避免层级过大)
|
||||||
// 2.5) 标题(一级→h3 二级→h4 三级→h5,避免层级过大)
|
|
||||||
esc=esc.replace(/^### (.+)$/gm,'<h5 style="margin:8px 0 4px;font-size:13px">$1</h5>');
|
esc=esc.replace(/^### (.+)$/gm,'<h5 style="margin:8px 0 4px;font-size:13px">$1</h5>');
|
||||||
esc=esc.replace(/^## (.+)$/gm,'<h4 style="margin:8px 0 4px;font-size:14px">$1</h4>');
|
esc=esc.replace(/^## (.+)$/gm,'<h4 style="margin:8px 0 4px;font-size:14px">$1</h4>');
|
||||||
esc=esc.replace(/^# (.+)$/gm,'<h3 style="margin:8px 0 4px;font-size:15px">$1</h3>');
|
esc=esc.replace(/^# (.+)$/gm,'<h3 style="margin:8px 0 4px;font-size:15px">$1</h3>');
|
||||||
// 2.6) 无序/有序列表 → <ul>/<ol>
|
// 无序列表 → <ul>(连续 - 行)
|
||||||
esc=esc.replace(/(?:^|\n)((?:[ \t]*[-*+] .+(?:\n|$))+)/g, function(_,blk){
|
esc=esc.replace(/(?:^|\n)((?:[ \t]*[-*+] .+(?:\n|$))+)/g, function(_,blk){
|
||||||
var items=blk.split('\n').filter(function(l){return l.trim();}).map(function(l){return '<li>'+l.replace(/^\s*[-*+]\s+/,'')+'</li>';});
|
var items=blk.split('\n').filter(function(l){return l.trim();}).map(function(l){return '<li>'+l.replace(/^\s*[-*+]\s+/,'')+'</li>';});
|
||||||
return '<ul style="margin:4px 0;padding-left:20px">'+items.join('')+'</ul>';
|
return '<ul style="margin:4px 0;padding-left:20px">'+items.join('')+'</ul>';
|
||||||
});
|
});
|
||||||
|
// 有序列表 → <ol>(连续 "1. " 行)
|
||||||
esc=esc.replace(/(?:^|\n)((?:\d+[.)] .+(?:\n|$))+)/g, function(_,blk){
|
esc=esc.replace(/(?:^|\n)((?:\d+[.)] .+(?:\n|$))+)/g, function(_,blk){
|
||||||
var items=blk.split('\n').filter(function(l){return l.trim();}).map(function(l){return '<li>'+l.replace(/^\s*\d+[.)]\s+/,'')+'</li>';});
|
var items=blk.split('\n').filter(function(l){return l.trim();}).map(function(l){return '<li>'+l.replace(/^\s*\d+[.)]\s+/,'')+'</li>';});
|
||||||
return '<ol style="margin:4px 0;padding-left:20px">'+items.join('')+'</ol>';
|
return '<ol style="margin:4px 0;padding-left:20px">'+items.join('')+'</ol>';
|
||||||
});
|
});
|
||||||
|
// 空行 → <br>
|
||||||
|
esc=esc.replace(/\n{2,}/g,'<br>');
|
||||||
// 3) 还原表格
|
// 3) 还原表格
|
||||||
for(var i=0;i<tbls.length;i++) esc=esc.replace('\u0000TBL'+i+'\u0000', tbls[i]);
|
for(var i=0;i<tbls.length;i++) esc=esc.replace('\u0000TBL'+i+'\u0000', tbls[i]);
|
||||||
// 4) 还原代码块(带操作栏:复制到编辑器 / 复制)
|
// 4) 还原代码块(带操作栏:复制到编辑器 / 复制)
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户