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 ? '...' : ''}

` : ''}