From abb8ad13250103ce08396ef5102d620bdebda02e Mon Sep 17 00:00:00 2001 From: thug0bin Date: Wed, 4 Mar 2026 19:33:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8F=99=EB=AC=BC=EC=95=BD=20=EC=95=88?= =?UTF-8?q?=EB=82=B4=EC=84=9C=20=ED=95=AD=EB=AA=A9=EB=B3=84=20=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 가. 나. 다. 라. 등 항목 앞에 줄바꿈 추가 - 1) 2) 3) 등 번호 앞에 들여쓰기 + 줄바꿈 - 미리보기/인쇄 모두 적용 - white-space: pre-line으로 줄바꿈 표시 - 80mm 프린터 출력에 최적화 --- backend/app.py | 46 +++++++++++++++++++++------ backend/templates/admin_products.html | 6 ++-- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/backend/app.py b/backend/app.py index 9335cc9..b989b3b 100644 --- a/backend/app.py +++ b/backend/app.py @@ -6480,6 +6480,18 @@ def api_animal_drug_info_print(): text = re.sub(r'\s+', ' ', text).strip() return text + # 항목별 줄바꿈 처리 (가. 나. 다. 라. / 1) 2) 3) 등) + def format_for_print(text): + if not text: + return '' + # 가. 나. 다. 라. 마. 바. 사. 아. 자. 앞에 줄바꿈 + text = re.sub(r'\s*(가|나|다|라|마|바|사|아|자)\.\s*', r'\n\1. ', text) + # 1) 2) 3) 등 앞에 줄바꿈 (단, 문장 시작이 아닌 경우) + text = re.sub(r'\s+(\d+)\)\s*', r'\n \1) ', text) + # 첫 줄바꿈 제거 + text = text.strip() + return text + # 텍스트를 줄 단위로 분리 (80mm ≈ 42자) def wrap_text(text, width=40): lines = [] @@ -6532,24 +6544,30 @@ def api_animal_drug_info_print(): {THIN} ▶ 효능효과 """ - for line in wrap_text(efficacy[:400], 46): - message += f" {line}\n" + formatted_efficacy = format_for_print(efficacy[:400]) + for para in formatted_efficacy.split('\n'): + for line in wrap_text(para.strip(), 44): + message += f" {line}\n" if dosage: message += f""" {THIN} ▶ 용법용량 """ - for line in wrap_text(dosage[:500], 46): - message += f" {line}\n" + 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""" {THIN} ▶ 주의사항 """ - for line in wrap_text(precautions[:400], 46): - message += f" {line}\n" + formatted_precautions = format_for_print(precautions[:600]) + for para in formatted_precautions.split('\n'): + for line in wrap_text(para.strip(), 44): + message += f" {line}\n" message += f""" {LINE} @@ -6623,15 +6641,25 @@ def api_animal_drug_info_preview(): text = re.sub(r'\s+', ' ', text).strip() return text + # 항목별 줄바꿈 처리 (가. 나. 다. 라. / 1) 2) 3) 등) + def format_items(text): + if not text: + return '' + # 가. 나. 다. 라. 마. 바. 사. 아. 자. 앞에 줄바꿈 + text = re.sub(r'\s*(가|나|다|라|마|바|사|아|자)\.\s*', r'\n\1. ', text) + # 1) 2) 3) 등 앞에 줄바꿈 + text = re.sub(r'\s+(\d+)\)\s*', r'\n \1) ', text) + return text.strip() + return jsonify({ 'success': True, 'data': { 'product_name': row.product_name, 'company_name': row.company_name, 'main_ingredient': row.main_ingredient if row.main_ingredient != 'NaN' else None, - 'efficacy_effect': strip_html(row.efficacy_effect), - 'dosage_instructions': strip_html(row.dosage_instructions), - 'precautions': strip_html(row.precautions) + 'efficacy_effect': format_items(strip_html(row.efficacy_effect)), + 'dosage_instructions': format_items(strip_html(row.dosage_instructions)), + 'precautions': format_items(strip_html(row.precautions)) } }) diff --git a/backend/templates/admin_products.html b/backend/templates/admin_products.html index ddfd2d4..8d30a2f 100644 --- a/backend/templates/admin_products.html +++ b/backend/templates/admin_products.html @@ -1150,19 +1150,19 @@ ${info.efficacy_effect ? `
▶ 효능효과
-

${escapeHtml(info.efficacy_effect)}

+

${escapeHtml(info.efficacy_effect)}

` : ''} ${info.dosage_instructions ? `
▶ 용법용량
-

${escapeHtml(info.dosage_instructions)}

+

${escapeHtml(info.dosage_instructions)}

` : ''} ${info.precautions ? `
▶ 주의사항
-

${escapeHtml(info.precautions.substring(0, 500))}${info.precautions.length > 500 ? '...' : ''}

+

${escapeHtml(info.precautions.substring(0, 800))}${info.precautions.length > 800 ? '...' : ''}

` : ''}