Merge remote-tracking branch 'origin/CODEX' into main_laptop_1 — 챗봇 출처 보기 · 여러 줄 입력(전역 깃 싱크)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LLCk2y5xE8YGVgjbTntWsY
This commit is contained in:
@@ -43,14 +43,36 @@ export function renderHelpMarkdown(text: string): string {
|
||||
const out: string[] = [];
|
||||
let list: "ul" | "ol" | null = null;
|
||||
let para: string[] = [];
|
||||
const lines = text.split(/\r?\n/);
|
||||
const cells = (line: string): string[] =>
|
||||
line
|
||||
.trim()
|
||||
.replace(/^\||\|$/g, "")
|
||||
.split("|")
|
||||
.map((cell) => cell.trim());
|
||||
const separator = (line: string): boolean =>
|
||||
cells(line).every((cell) => /^:?-{3,}:?$/.test(cell));
|
||||
const flush = (): void => {
|
||||
if (para.length) out.push(`<p>${para.map(inline).join("<br>")}</p>`);
|
||||
para = [];
|
||||
if (list) out.push(`</${list}>`);
|
||||
list = null;
|
||||
};
|
||||
for (const raw of text.split(/\r?\n/)) {
|
||||
for (let index = 0; index < lines.length; index += 1) {
|
||||
const raw = lines[index];
|
||||
const line = raw.trim();
|
||||
if (line.includes("|") && lines[index + 1]?.includes("|") && separator(lines[index + 1])) {
|
||||
flush();
|
||||
const headers = cells(line);
|
||||
const rows: string[][] = [];
|
||||
index += 2;
|
||||
while (index < lines.length && lines[index].includes("|")) rows.push(cells(lines[index++]));
|
||||
index -= 1;
|
||||
out.push(
|
||||
`<div class="ui-markdown-table"><table><thead><tr>${headers.map((cell) => `<th>${inline(cell)}</th>`).join("")}</tr></thead><tbody>${rows.map((row) => `<tr>${headers.map((_, cell) => `<td>${inline(row[cell] ?? "")}</td>`).join("")}</tr>`).join("")}</tbody></table></div>`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const head = /^(#{1,4})\s+(.*)$/.exec(line);
|
||||
const item = /^(?:([-*])|\d+\.)\s+(.*)$/.exec(line);
|
||||
if (!line) flush();
|
||||
|
||||
Reference in New Issue
Block a user