From 5a2ab044baae09e1be8ba31f517d9d934b871bb8 Mon Sep 17 00:00:00 2001 From: thug0bin Date: Wed, 4 Mar 2026 19:58:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=88=AC=EC=95=BD=EC=A7=80=EB=8F=84?= =?UTF-8?q?=EC=84=9C=20=ED=91=9C=20=ED=98=95=EC=8B=9D=20=EC=B6=9C=EB=A0=A5?= =?UTF-8?q?=20=EC=A7=80=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 체중/투여정수 표(─ 문자 포함) 감지 - 표 형식일 때 공백/정렬 유지 - 안텔민 킹정 등 체중별 투여량 표 정상 출력 --- backend/app.py | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/backend/app.py b/backend/app.py index df42722..47dd420 100644 --- a/backend/app.py +++ b/backend/app.py @@ -6472,13 +6472,27 @@ def api_animal_drug_info_print(): def strip_html(html_text): if not html_text: return '' - # HTML 태그 제거 - text = re.sub(r'<[^>]+>', '', html_text) + # HTML 태그 제거 (줄바꿈 보존) + #

,
, 등을 줄바꿈으로 변환 + text = re.sub(r'

||', '\n', html_text) + text = re.sub(r'<[^>]+>', '', text) # HTML 엔티티 변환 text = unescape(text) - # 연속 공백/줄바꿈 정리 - text = re.sub(r'\s+', ' ', text).strip() - return text + + # 표 형식 감지 (─ 문자 포함) + if '─' in text or '━' in text: + # 표 형식: 각 줄의 앞뒤 공백만 정리, 줄 내 공백은 유지 + lines = text.split('\n') + cleaned = [] + for line in lines: + line = line.strip() + if line: + cleaned.append(line) + return '\n'.join(cleaned) + else: + # 일반 텍스트: 연속 공백/줄바꿈 정리 + text = re.sub(r'\s+', ' ', text).strip() + return text # 항목별 줄바꿈 처리 (가. 나. 다. 라. / 1) 2) 3) 등) def format_for_print(text): @@ -6554,10 +6568,18 @@ def api_animal_drug_info_print(): {THIN} ▶ 용법용량 """ - formatted_dosage = format_for_print(dosage[:500]) - for para in formatted_dosage.split('\n'): - for line in wrap_text(para.strip(), 44): - message += f" {line}\n" + # 표 형식 감지 (─ 문자 포함) + if '─' in dosage or '━' in dosage: + # 표 형식: 줄바꿈 유지, 공백 유지 + for line in dosage.split('\n'): + line = line.strip() + if line: + message += f"{line}\n" + else: + formatted_dosage = format_for_print(dosage[:500]) + for para in formatted_dosage.split('\n'): + for line in wrap_text(para.strip(), 44): + message += f" {line}\n" if precautions: message += f"""