diff --git a/A00_Common/line_stack_machine_ctl.ts b/A00_Common/line_stack_machine_ctl.ts index 2df0e34e8..aad4d4dcb 100644 --- a/A00_Common/line_stack_machine_ctl.ts +++ b/A00_Common/line_stack_machine_ctl.ts @@ -77,7 +77,8 @@ export const diffOf = (src: Source | undefined): UiDiff | null => /** 칸 묶음 안 입력 · 고르기 · 이름 단추에 「바뀜」 상태 · 풍선(원래 값) */ export function markDiff(box: HTMLElement, diff: UiDiff | null, was?: string): void { - const nodes = box.matches(".ui-input, .ui-select, .ui-btn") ? [box] : [...box.querySelectorAll(".ui-input, .ui-select, .ui-btn.lstk-res")]; // prettier-ignore + const own = ["ui-input", "ui-select", "ui-btn"].some((c) => box.classList.contains(c)); + const nodes = own ? [box] : ["ui-input", "ui-select", "lstk-res"].flatMap((c) => [...box.querySelectorAll(`.${c}`)]); // prettier-ignore for (const n of nodes) { setUiDiff(n, diff); if (diff && was !== undefined) diff --git a/A00_Common/line_stack_out.ts b/A00_Common/line_stack_out.ts index e77d05e4e..e74038bcf 100644 --- a/A00_Common/line_stack_out.ts +++ b/A00_Common/line_stack_out.ts @@ -241,9 +241,11 @@ function rows( const v = vals[id]; const t = lines.get(id); const head = katexNode(symTex(alias[id] ?? id)); - if (t !== undefined && hasVar(t)) { + const tn = t === undefined ? null : nodeOf(t); + // 848-3 수만인 식도 두 층 넘는 분수면(가져온 공식 줄 `Q = (4.5 + 5.5) ÷ 2 ÷ 0.35` 꼴) 아래 줄 나눔 규칙으로 + if (t !== undefined && (hasVar(t) || (tn && fracDepth(tn) > 1))) { flush(); - const n = nodeOf(t)!; + const n = tn!; if (!machine && fracDepth(n) <= 1) { push({ h: formula(id, n, v, unit(id), vals, {}) }); continue; diff --git a/resources/tester/test_848_3_import_frac.py b/resources/tester/test_848_3_import_frac.py new file mode 100644 index 000000000..f97d9eb7d --- /dev/null +++ b/resources/tester/test_848_3_import_frac.py @@ -0,0 +1,44 @@ +"""848-3(조사 889b F) — 가져온 공식 줄의 수만인 겹분수도 산출근거에서 두 층 안(줄 나눔 규칙) · 금액 · 문서 그대로. + +짝 = `A00_Common/line_stack_out.ts` 공식 묶음(`block` — 수만인 식이 두 층 넘는 분수면 중간 줄 길) · +그리기 = 진짜 화면 코드를 가짜 DOM 으로(`helper_845_2_unit_show.cjs` 「전수」 · 기계 줄 = 위 · 아래 모두 봄). +견본 = EST main 33(석축헐기 Q = (4.5 + 5.5) ÷ 2 ÷ 0.35) · 엑셀 북부청임도 43 — 엑셀 · 우리 두 판. +""" + +import pytest + +from M02_MasterTemplete import M02_Doc_Copy as dc +from M02_MasterTemplete import M02_Doc_FromNative as fn +from M02_MasterTemplete import M02_Doc_Import as dim +from M02_MasterTemplete import M02_San_Xlsx as sx +from M02_MasterTemplete import M02_Sangeun_Imported as imp +from resources.tester import test_797_1a_import_flags as practice +from resources.tester import test_810_1_estx as e +from resources.tester import test_810_2_native_doc as t +from resources.tester import test_846_2_work_view as w2 + + +def _saved(kind: str, tag: str): + if kind == "엑셀": + p = practice.FILES[tag] + return fn.pack(sx.read(p.name, p.read_bytes()), p.name) + p = e.FILES[tag] + return fn.read(p.name, p.read_bytes()) + + +@pytest.mark.parametrize("kind,tag,no", [("EST", "main", 33), ("엑셀", "북부청임도", 43)]) +def test_가져온_식_겹분수_두_층_안(kind, tag, no): + p = (practice.FILES if kind == "엑셀" else e.FILES)[tag] + if not p or not p.exists(): + pytest.skip("견본 파일 없음") + sk = t.sk_of(fn.emit(_saved(kind, tag), no)) + doc = dim.derive(sk, None, t.whole()) + cases = [] + for basis in ("엑셀", "우리"): + sk2 = {**sk, imp.KEY: {**sk[imp.KEY], "단가기준": basis}} + cases.append( + {"키": basis, "문서": dim.view(doc, basis), "연결": dim.record(doc, sk2), "기계": True} + ) + got = w2._js({"할일": "전수", "문서들": dc.ml._norm(cases), "보기": []}) + assert [b for g in got for b in g["bad"] if b[0] == "겹분수"] == [] + assert all(g["같음"] for g in got)