This commit is contained in:
MarkLo 2025-11-27 04:10:14 +08:00
parent 44705c79a7
commit 4e21142757
5 changed files with 19 additions and 189 deletions

View File

@ -330,8 +330,9 @@ class PDFGenerator:
text = re.sub(r'```[^`]*?```', '', text, flags=re.DOTALL)
text = re.sub(r'`([^`]+?)`', r'\1', text)
# 5. Clean up bullet points
text = re.sub(r'^\s*[\*\-\+]\s+', '', text, flags=re.MULTILINE)
# 5. Clean up bullet points - USE ASCII DASH, NOT UNICODE BULLET
# Unicode bullet • (U+2022) renders as '煉' in STSong-Light font!
text = re.sub(r'^\s*[\*\-\+]\s+', '- ', text, flags=re.MULTILINE)
# 6. Remove horizontal rules
text = re.sub(r'^[\-\*_]{3,}\s*$', '', text, flags=re.MULTILINE)

View File

@ -330,6 +330,22 @@ export default function HomePage() {
/>
</div>
</div>
{/* Call to Action Section */}
<div className="text-center py-16">
<h2 className="text-3xl font-bold mb-4"></h2>
<p className="text-lg text-gray-600 dark:text-gray-400 mb-8 max-w-2xl mx-auto">
12 AI
</p>
<Link href="/analysis">
<Button
size="lg"
className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 text-lg px-8 py-6"
>
</Button>
</Link>
</div>
</div>
);
}

View File

@ -1,93 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
最簡單的解決方案完全移除可能導致問題的 Unicode 符號
改用最安全的 ASCII 和基本中文字符
"""
# 問題分析:
# STSong-Light 對某些 Unicode 符號的支持不完整
# 可能將某些符號(如 ★ ※ ◈ 等)錯誤渲染為「煉」
# 解決方案:
# 1. 完全移除這些 Unicode 符號
# 2. 改用 ASCII 字符或簡單的中文文字
# 3. 如果必須使用符號,只使用最基本的 ASCII 符號
SAFE_EMOJI_MAPPING = {
# Status - 使用 ASCII
'': '[OK]',
'': '[X]',
'⚠️': '[!]',
'': '*',
'🔔': 'o',
# Rating - 使用 ASCII
'': '*',
'🌟': '*',
'💎': '+',
'🏆': '#',
# Charts - 使用簡單文字
'📊': '', # 完全移除
'📈': '^', # 向上
'📉': 'v', # 向下
'📋': '-',
'📌': '*',
# Money - 保留貨幣符號(這些是安全的)
'💰': '$',
'💵': '$',
'💴': 'Y', # 改用 ASCII Y 代替 ¥
'💶': 'E', # 改用 ASCII E 代替 €
'💷': 'P', # 改用 ASCII P 代替 £
'💸': '$',
'💹': '^',
# Direction - 使用 ASCII
'🚀': '^^',
'⬆️': '^',
'⬇️': 'v',
'➡️': '>',
'⬅️': '<',
'🔼': '^',
'🔽': 'v',
# Symbols - 純 ASCII
'🎯': 'o',
'🔥': '*',
'💡': '*',
'⚙️': '*',
'🔧': '>',
'🔨': '>',
# Tech - 全部移除或改 ASCII
'🤖': '',
'💻': '',
'📱': '',
'🖥️': '',
# People - 全部移除
'👤': '',
'👥': '',
'🔬': '',
'📚': '',
# Time - 純 ASCII
'': 'o',
'📅': '-',
'⏱️': 'o',
# Other - 純 ASCII 或移除
'': '*',
'🎨': '',
'📝': '-',
'📄': '-',
'🗂️': '=',
'🌐': 'o',
'🔗': '~',
'💼': '',
}
print("安全的 Emoji 映射(只使用 ASCII 和基本字符):")
print(SAFE_EMOJI_MAPPING)

View File

@ -1,38 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.insert(0, '/Users/yaolo/Desktop/TradingAgentsX')
from backend.app.services.pdf_generator import PDFGenerator
# 測試包含各種符號的內容
test_content = '''# 測試報告
## 市場分析
- 上漲趨勢 ^
- 技術指標 *
- 支撐位 o
## 風險評估
- 警告標記 [!]
- 確認標記 [OK]
- 否定標記 [X]
## 結論
純文字和 ASCII 符號測試不應該出現
'''
pdf_gen = PDFGenerator()
pdf_bytes = pdf_gen.generate_analyst_report_pdf(
analyst_name='ASCII 符號測試',
ticker='TEST',
analysis_date='2025-11-27',
report_content=test_content
)
with open('/tmp/test_ascii_only.pdf', 'wb') as f:
f.write(pdf_bytes)
print('✓ 已生成測試 PDF: /tmp/test_ascii_only.pdf')
print('請檢查 PDF 中是否還有「煉」字出現')
print('如果沒有「煉」,說明 ASCII-only 方案成功解決問題')

View File

@ -1,56 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
測試找出哪個字符在 STSong-Light 中被渲染為
"""
import sys
sys.path.insert(0, '/Users/yaolo/Desktop/TradingAgentsX')
from backend.app.services.pdf_generator import PDFGenerator
import io
# 測試內容 - 包含我們使用的所有符號
test_symbols = {
'星號': '',
'菱形': '',
'方塊': '',
'小方': '',
'雙菱': '',
'空菱': '',
'雙圓': '',
'米字': '',
'時鐘': '',
'': '',
'無限': '',
'粗方': '',
'對號': '',
'叉號': '',
'警告': '',
'閃電': '',
}
print("測試每個符號在 PDF 中的渲染...\n")
pdf_gen = PDFGenerator()
for name, symbol in test_symbols.items():
test_content = f"測試{name}符號: {symbol}"
try:
pdf_bytes = pdf_gen.generate_analyst_report_pdf(
analyst_name=f"測試: {symbol}",
ticker="TEST",
analysis_date="2025-11-27",
report_content=test_content
)
# 保存測試 PDF
filename = f"/tmp/test_symbol_{name}.pdf"
with open(filename, 'wb') as f:
f.write(pdf_bytes)
print(f"{name} ({symbol}) - U+{ord(symbol):04X} - 已生成: {filename}")
except Exception as e:
print(f"{name} ({symbol}) - 錯誤: {e}")
print("\n請手動檢查 /tmp/test_symbol_*.pdf 文件,看看哪個符號顯示為「煉」")