fix(833-1): 원문 패널 표 깨짐 — 표 맨 아래 비고 · [주] · ※ 서술 줄을 표 밖 글로 · 서술 칸 줄바꿈

- 새 순수 계산 logic/M01_MasterData_logic_source_notes.ts (서술 줄 가르기 · 줄바꿈 칸 판정) · 원문 글 · 차례 그대로
- 원문 표 2,573 · 폭 420 기준 서술 줄 때문에 넘친 표 138 → 0 · 넘침 1,228 → 1,020
- 시험 test_833_1_source_notes (보기 + 전수 글 보존)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 10:06:06 +09:00
co-authored by Claude Sonnet 5.5
parent 2a38ad51b2
commit 5e6037270e
4 changed files with 184 additions and 4 deletions
@@ -79,3 +79,19 @@ html:not([data-size="compact"], [data-size="medium"]) .m01-master__panel .m01-lo
.m01lab-src__find .ui-find__list {
max-height: 40vh;
}
/* 표 + 표 아래 비고 · [주] 글(833-1) — 글은 패널 폭 그대로 접힘 */
.m01lab-src__tblwrap {
display: flex;
flex-direction: column;
gap: var(--spacing-8);
min-width: 0;
}
/* 서술 칸(한 줄 30자 이상) · 한 칸짜리 표 — 접고, 너무 좁게 찌그러지지 않게 */
.m01lab-src .m01lab-src__table td.m01lab-src__wrapcell {
white-space: pre-wrap;
overflow-wrap: anywhere;
min-width: 14em;
max-width: 28em;
}
@@ -8,6 +8,7 @@
import { currentLanguageIndex } from "@ui/ui_template_locale";
import { el } from "@ui/ui_template_elements";
import { API_BASE_URL } from "@config/config_frontend";
import { splitTableNotes, wrapCell } from "./logic/M01_MasterData_logic_source_notes";
import "./M01_MasterData_UI_LogicLab_Side.css";
const TEXT = {
@@ -48,22 +49,45 @@ function blockNode(b: Block): HTMLElement {
}
function rawNode(b: Block): HTMLElement {
if (b.table)
return el("div", {
if (b.table) {
// 표 맨 아래 비고 · [주] · ※ 줄 = 표 밖 글로(833-1) — 긴 글이 열 폭을 밀지 않게
const { rows, notes } = splitTableNotes(b.table);
const grid = el("div", {
className: "m01-logic__scroll",
children: [
el("table", {
className: "ui-table ui-table--data m01-logic__grid m01lab-src__table",
children: [
el("tbody", {
children: b.table.map((r) =>
el("tr", { children: r.map((c) => el("td", { text: c })) }),
children: rows.map((r) =>
el("tr", {
children: r.map((c) =>
el("td", {
text: c,
className: wrapCell(c, r.length) ? "m01lab-src__wrapcell" : "",
}),
),
}),
),
}),
],
}),
],
});
if (!notes.length) return grid;
return el("div", {
className: "m01lab-src__tblwrap",
children: [
grid,
...notes.map((n) =>
el("p", {
className: "m01lab-src__p m01lab-src__tnote",
children: [...(n.label ? [el("strong", { text: n.label }), " "] : []), n.text],
}),
),
],
});
}
if (b.h) return el("h4", { className: "m01lab-src__head", text: b.text ?? "" });
return el("p", { className: "m01lab-src__p", text: b.p ?? "" });
}
@@ -0,0 +1,43 @@
/* =============================================================================
* M01_MasterData_logic_source_notes.ts
* 원문 표 맨 아래 서술 줄(비고 · [주] · ※ …) 가르기 — 순수 계산(화면 · fetch 없음 · PLAN 833-1)
* 표 끝에 이어 붙은 서술 줄 = 표 밖 글로 · 글 순서 · 내용은 그대로 · 위쪽 줄(표 몸 · 묶음 머리)은 안 건드림
* ========================================================================== */
/** 표 밖으로 나가는 서술 줄 하나 — `label` = 「비고」 · 「[주]」 머리(없으면 빈 글) */
export interface NoteLine {
label: string;
text: string;
}
const LABEL = /^(비고|\[?주\]?\)?|※|참고)\s*\d*$/;
const MARK = /^(※|-|∙|·|\[주\]|주\)|비고|참고)/;
const LONG = 30;
/** 한 줄이 서술 줄이면 글 — 아니면 null (머리 줄 · 숫자 줄 · 묶음 머리(짧은 한 칸)는 아님) */
export function noteLine(row: string[]): NoteLine | null {
if (row.length < 2) return null;
const full = row.map((c, k) => [k, c.trim()] as const).filter(([, c]) => c);
if (full.length === 1) {
const [[, text]] = full;
return MARK.test(text) || text.length >= LONG ? { label: "", text } : null;
}
if (full.length === 2 && full[0][0] === 0 && LABEL.test(full[0][1]))
return { label: full[0][1], text: full[1][1] };
return null;
}
/** 표 → 몸 줄 + 맨 아래 이어 붙은 서술 줄 — 머리(첫 줄)는 늘 몸 */
export function splitTableNotes(table: string[][]): { rows: string[][]; notes: NoteLine[] } {
let end = table.length;
while (end > 1 && noteLine(table[end - 1])) end--;
return {
rows: table.slice(0, end),
notes: table.slice(end).map((r) => noteLine(r) as NoteLine),
};
}
/** 칸 글이 줄바꿈 대상 — 한 줄이 30자 이상(서술 칸) · 한 칸짜리 표(글 상자) · 숫자 칸은 안 접음 */
export function wrapCell(text: string, cols: number): boolean {
return cols === 1 || text.split("\n").some((l) => l.length >= LONG);
}