fix(802-3): 선택으로 꺼진 금액 줄 숨김 · 값 식 한 번 · 옮김 군더더기 걷음(브레인 사진 지적)

- 663-1: 수량 · 단가가 만약으로 0 을 탄 금액 줄 = 안 보임(GC000211 폼타이 9.5 · 7.9 ㎜) · 규격 바꾸면 그 줄만 · [선택으로 꺼진 줄 보기] = 고침 모드에서만 · 정의 영역도 꺼진 줄 기호 뺌
  1,518 문서 금액 줄 5,912 중 기본 옵션에서 꺼짐 145 줄(107 문서) · 옵션에 따라 꺼질 수 있는 줄 305 줄(141 문서)
- 식 안 만약이 0 · 1 을 타면 그 항(+ 0 · × 1)도 안 보임 — 고침 글은 그대로
- 수 하나 · 기호 하나 줄 값 식 = 한 번만(「= 1 = 1」 없음) · 수량 없음 「× 1」 자리는 줄에 마우스 올릴 때만
- 옮김 slim(master_doc_convert) — + 0 · × 1 · ÷ 1 지움 · A × k ÷ 100 → A × k% · 빌더 다시(목록 xlsx 는 안 씀) · 대조 그대로(기본 1,519 같음 · 옵션 다름 1 · 저장 1,518) · 31 파일 글만
- 시험 test_802_3 + 군더더기 없음 1(12) · 802_1 · 802_2 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 19:43:00 +09:00
co-authored by Claude Opus 5.5
parent 54fb55487c
commit a003587aca
38 changed files with 693 additions and 568 deletions
@@ -325,7 +325,53 @@ def convert(master, row: dict, given: dict | None = None) -> tuple[dict, list[st
c.reg.settle()
doc = _build(c, row, given, lone_steps)
c.notes += c.reg.notes
return doc, sorted(set(c.notes))
return slim_doc(doc), sorted(set(c.notes))
def _is(node, value) -> bool:
return node[0] == "num" and node[1] == value
def slim(node):
"""옮김 군더더기 걷기(802-3) — `+ 0` · `- 0` · `× 1` · `÷ 1` 지움 · `A × k ÷ 100` → `A × k%`(값 같음)."""
kind = node[0]
if kind == "bin":
op, a, b = node[1], node[2], node[3]
if op == "/" and _is(b, 100) and a[0] == "bin" and a[1] == "*" and a[3][0] == "num":
return ("bin", "*", slim(a[2]), ("pct", a[3]))
a, b = slim(a), slim(b)
if (op in ("+", "-") and _is(b, 0)) or (op in ("*", "/") and _is(b, 1)):
return a
if (op == "+" and _is(a, 0)) or (op == "*" and _is(a, 1)):
return b
return ("bin", op, a, b)
if kind in ("neg", "pct"):
return (kind, slim(node[1]))
if kind == "field":
return ("field", slim(node[1]), node[2])
if kind == "call":
return ("call", node[1], [slim(x) for x in node[2]])
return node
def _slim_text(text):
if not isinstance(text, str) or not text.strip():
return text
try:
return md.text_of(slim(md.parse(text)))
except md.DocError:
return text
def slim_doc(doc: dict) -> dict:
"""식 줄 · 금액 줄(수량 · 단가) 글에 `slim`."""
for line in doc.get("식") or []:
line["식"] = _slim_text(line.get("식"))
for line in doc.get("금액") or []:
for k in ("수량", "단가"):
if k in line:
line[k] = _slim_text(line[k])
return doc
def _link_of(c: _Conv, node) -> dict: