@wendongfly/myhi 1.3.32 → 1.3.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat.html +45 -7
- package/package.json +1 -1
package/dist/chat.html
CHANGED
|
@@ -62,6 +62,14 @@
|
|
|
62
62
|
.msg-assistant .content pre code { background: none; padding: 0; }
|
|
63
63
|
.msg-assistant .content ul, .msg-assistant .content ol { padding-left: 1.5rem; margin: 0.3rem 0; }
|
|
64
64
|
.msg-assistant .content strong { color: #fff; }
|
|
65
|
+
.msg-assistant .content a { color: #58a6ff; text-decoration: none; word-break: break-all; }
|
|
66
|
+
.msg-assistant .content a:hover { text-decoration: underline; }
|
|
67
|
+
.md-table { border-collapse: collapse; margin: 0.5rem 0; font-size: 0.82rem; width: 100%; display: block; overflow-x: auto; white-space: nowrap; }
|
|
68
|
+
.md-table thead { background: #161b22; }
|
|
69
|
+
.md-table th, .md-table td { border: 1px solid #30363d; padding: 0.4rem 0.7rem; text-align: left; }
|
|
70
|
+
.md-table th { color: #fff; font-weight: 600; }
|
|
71
|
+
.md-table tbody tr:nth-child(even) { background: #0d1117; }
|
|
72
|
+
.md-table tbody tr:hover { background: #1c2128; }
|
|
65
73
|
|
|
66
74
|
/* 工具调用组 */
|
|
67
75
|
.msg-tool-group { border-left: 3px solid #58a6ff; margin-left: 0.3rem; padding-left: 0.6rem; margin-bottom: 0.3rem; }
|
|
@@ -678,7 +686,21 @@
|
|
|
678
686
|
let html = '';
|
|
679
687
|
let inCode = false, codeLang = '', codeLines = [];
|
|
680
688
|
|
|
681
|
-
|
|
689
|
+
// 行内格式化辅助函数
|
|
690
|
+
const fmtInline = (s) => s
|
|
691
|
+
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
|
692
|
+
.replace(/\*(.+?)\*/g, '<em>$1</em>')
|
|
693
|
+
.replace(/`([^`]+)`/g, '<code>$1</code>')
|
|
694
|
+
.replace(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>');
|
|
695
|
+
|
|
696
|
+
// 表格检测:| ... | 后跟 |---|---| 分隔行
|
|
697
|
+
const isTableRow = (s) => /^\s*\|(.+)\|\s*$/.test(s);
|
|
698
|
+
const isTableSep = (s) => /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)+\|?\s*$/.test(s);
|
|
699
|
+
const splitCells = (s) => s.trim().replace(/^\||\|$/g, '').split('|').map(c => c.trim());
|
|
700
|
+
|
|
701
|
+
for (let i = 0; i < lines.length; i++) {
|
|
702
|
+
const line = lines[i];
|
|
703
|
+
|
|
682
704
|
if (!inCode && /^```(\w*)/.test(line)) {
|
|
683
705
|
inCode = true; codeLang = line.match(/^```(\w*)/)[1]; codeLines = [];
|
|
684
706
|
continue;
|
|
@@ -689,15 +711,31 @@
|
|
|
689
711
|
}
|
|
690
712
|
if (inCode) { codeLines.push(line); continue; }
|
|
691
713
|
|
|
714
|
+
// 表格
|
|
715
|
+
if (isTableRow(line) && i + 1 < lines.length && isTableSep(lines[i + 1])) {
|
|
716
|
+
const header = splitCells(line);
|
|
717
|
+
let tableHtml = '<table class="md-table"><thead><tr>' +
|
|
718
|
+
header.map(c => `<th>${fmtInline(escHtml(c))}</th>`).join('') +
|
|
719
|
+
'</tr></thead><tbody>';
|
|
720
|
+
i += 2; // 跳过表头和分隔行
|
|
721
|
+
while (i < lines.length && isTableRow(lines[i])) {
|
|
722
|
+
const cells = splitCells(lines[i]);
|
|
723
|
+
tableHtml += '<tr>' + cells.map(c => `<td>${fmtInline(escHtml(c))}</td>`).join('') + '</tr>';
|
|
724
|
+
i++;
|
|
725
|
+
}
|
|
726
|
+
tableHtml += '</tbody></table>';
|
|
727
|
+
html += tableHtml;
|
|
728
|
+
i--; // 回退一步让外层 for 循环正确递增
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
|
|
692
732
|
let l = escHtml(line);
|
|
693
733
|
// 标题
|
|
694
|
-
if (/^### /.test(l)) { html += `<h4>${l.slice(4)}</h4>`; continue; }
|
|
695
|
-
if (/^## /.test(l)) { html += `<h3>${l.slice(3)}</h3>`; continue; }
|
|
696
|
-
if (/^# /.test(l)) { html += `<h2>${l.slice(2)}</h2>`; continue; }
|
|
734
|
+
if (/^### /.test(l)) { html += `<h4>${fmtInline(l.slice(4))}</h4>`; continue; }
|
|
735
|
+
if (/^## /.test(l)) { html += `<h3>${fmtInline(l.slice(3))}</h3>`; continue; }
|
|
736
|
+
if (/^# /.test(l)) { html += `<h2>${fmtInline(l.slice(2))}</h2>`; continue; }
|
|
697
737
|
// 行内格式
|
|
698
|
-
l = l
|
|
699
|
-
l = l.replace(/\*(.+?)\*/g, '<em>$1</em>');
|
|
700
|
-
l = l.replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
738
|
+
l = fmtInline(l);
|
|
701
739
|
// 列表
|
|
702
740
|
if (/^- /.test(l)) { html += `<li>${l.slice(2)}</li>`; continue; }
|
|
703
741
|
if (/^\d+\. /.test(l)) { html += `<li>${l.replace(/^\d+\.\s*/, '')}</li>`; continue; }
|