|
|
@@ -200,11 +200,12 @@ class OCRLayoutManager:
|
|
|
return display_content, render_mode
|
|
|
|
|
|
def render_content_by_mode(self, content: str, render_mode: str, font_size: int, layout_type: str):
|
|
|
- """根据渲染模式显示内容 - 统一方法"""
|
|
|
+ """根据渲染模式显示内容 - 增强版本"""
|
|
|
if content is None or render_mode is None:
|
|
|
return
|
|
|
|
|
|
if render_mode == "HTML渲染":
|
|
|
+ # 增强的HTML渲染样式,支持横向滚动
|
|
|
content_style = f"""
|
|
|
<style>
|
|
|
.{layout_type}-content-display {{
|
|
|
@@ -215,6 +216,37 @@ class OCRLayoutManager:
|
|
|
padding: 10px;
|
|
|
border-radius: 5px;
|
|
|
border: 1px solid #ddd;
|
|
|
+ overflow-x: auto;
|
|
|
+ max-width: 100%;
|
|
|
+ }}
|
|
|
+
|
|
|
+ .{layout_type}-content-display table {{
|
|
|
+ width: 100%;
|
|
|
+ border-collapse: collapse;
|
|
|
+ margin: 10px 0;
|
|
|
+ white-space: nowrap;
|
|
|
+ }}
|
|
|
+
|
|
|
+ .{layout_type}-content-display th,
|
|
|
+ .{layout_type}-content-display td {{
|
|
|
+ border: 1px solid #ddd;
|
|
|
+ padding: 8px;
|
|
|
+ text-align: left;
|
|
|
+ min-width: 100px;
|
|
|
+ }}
|
|
|
+
|
|
|
+ .{layout_type}-content-display th {{
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ position: sticky;
|
|
|
+ top: 0;
|
|
|
+ z-index: 1;
|
|
|
+ }}
|
|
|
+
|
|
|
+ .{layout_type}-content-display img {{
|
|
|
+ max-width: 100%;
|
|
|
+ height: auto;
|
|
|
+ border-radius: 4px;
|
|
|
+ margin: 10px 0;
|
|
|
}}
|
|
|
</style>
|
|
|
"""
|
|
|
@@ -223,21 +255,7 @@ class OCRLayoutManager:
|
|
|
|
|
|
elif render_mode == "Markdown渲染":
|
|
|
converted_content = convert_html_table_to_markdown(content)
|
|
|
- content_style = f"""
|
|
|
- <style>
|
|
|
- .{layout_type}-content-display {{
|
|
|
- font-size: {font_size}px !important;
|
|
|
- line-height: 1.4;
|
|
|
- color: #333333 !important;
|
|
|
- background-color: #fafafa !important;
|
|
|
- padding: 10px;
|
|
|
- border-radius: 5px;
|
|
|
- border: 1px solid #ddd;
|
|
|
- }}
|
|
|
- </style>
|
|
|
- """
|
|
|
- st.markdown(content_style, unsafe_allow_html=True)
|
|
|
- st.markdown(f'<div class="{layout_type}-content-display">{converted_content}</div>', unsafe_allow_html=True)
|
|
|
+ st.markdown(converted_content, unsafe_allow_html=True)
|
|
|
|
|
|
elif render_mode == "DataFrame表格":
|
|
|
if '<table' in content.lower():
|