#!/usr/bin/env python3 """ Tab3内容生成器 - 整体结构理解 包含:整体解构(节点基础信息、整体实质×形式、纵向逻辑流)、段落解构 """ import html as html_module from typing import Dict, Any, List def render_overall_deconstruction_card(overall: Dict[str, Any]) -> str: """渲染整体解构卡片""" card_id = "overall-deconstruction" html = f'
\n' html += f'
\n' html += '整体解构\n' html += '\n' html += '
\n' html += f'
\n' # 节点基础信息 basic_info = overall.get("节点基础信息", "") if basic_info: html += '
\n' html += '节点基础信息:\n' html += f'
{html_module.escape(basic_info)}
\n' html += '
\n' # 整体实质×形式 substance_form = overall.get("整体实质×形式", {}) if substance_form: html += '
\n' html += '整体实质×形式:\n' # 处理可能是字符串或字典的情况 if isinstance(substance_form, dict): if substance_form.get("抽象概念"): html += f'
抽象概念:{html_module.escape(substance_form["抽象概念"])}
\n' if substance_form.get("画面形式"): html += f'
画面形式:{html_module.escape(substance_form["画面形式"])}
\n' if substance_form.get("文案形式"): html += f'
文案形式:{html_module.escape(substance_form["文案形式"])}
\n' if substance_form.get("声音形式"): html += f'
声音形式:{html_module.escape(substance_form["声音形式"])}
\n' elif isinstance(substance_form, str): html += f'
{html_module.escape(substance_form)}
\n' html += '
\n' # 纵向逻辑流 logic_flow = overall.get("纵向逻辑流", []) if logic_flow: html += '
\n' html += '纵向逻辑流:\n' html += '
\n' for stage in logic_flow: stage_num = stage.get("阶段编号", "") stage_name = stage.get("阶段逻辑名称", "") stage_desc = stage.get("阶段逻辑描述", "") html += '
\n' if stage_num: html += f'
阶段 {stage_num}
\n' if stage_name: html += f'
{html_module.escape(stage_name)}
\n' if stage_desc: html += f'
{html_module.escape(stage_desc)}
\n' html += '
\n' html += '
\n' html += '
\n' html += '
\n' html += '
\n' return html def render_paragraph_card(paragraph: Dict[str, Any], idx: int) -> str: """渲染段落解构卡片""" para_num = paragraph.get("段落序号", idx) time_range = paragraph.get("时间范围", "") units = paragraph.get("包含单元", []) full_text = paragraph.get("段落完整文案", "") card_id = f'paragraph-{para_num}' html = f'
\n' html += f'
\n' html += f'段落 #{para_num}\n' if time_range: html += f'{html_module.escape(time_range)}\n' if units: units_str = ", ".join([str(u) for u in units]) html += f'包含单元: {units_str}\n' html += '\n' html += '
\n' html += f'
\n' # 段落完整文案 if full_text: html += '
\n' html += '段落完整文案:\n' html += f'
{html_module.escape(full_text)}
\n' html += '
\n' # 具体元素实质和形式 concrete_elements = paragraph.get("具体元素实质和形式", []) if concrete_elements: html += '
\n' html += '具体元素实质和形式:\n' for elem in concrete_elements: elem_name = elem.get("具体元素名称", "") html += '
\n' if elem_name: html += f'
{html_module.escape(elem_name)}
\n' if elem.get("对应形式-文案"): html += f'
对应形式-文案:{html_module.escape(elem["对应形式-文案"])}
\n' if elem.get("对应形式-画面"): html += f'
对应形式-画面:{html_module.escape(elem["对应形式-画面"])}
\n' if elem.get("对应形式-声音"): html += f'
对应形式-声音:{html_module.escape(elem["对应形式-声音"])}
\n' html += '
\n' html += '
\n' # 具象概念实质和形式 concrete_concepts = paragraph.get("具象概念实质和形式", []) if concrete_concepts: html += '
\n' html += '具象概念实质和形式:\n' for concept in concrete_concepts: concept_name = concept.get("具象概念名称", "") html += '
\n' if concept_name: html += f'
{html_module.escape(concept_name)}
\n' if concept.get("对应形式-文案"): html += f'
对应形式-文案:{html_module.escape(concept["对应形式-文案"])}
\n' if concept.get("对应形式-画面"): html += f'
对应形式-画面:{html_module.escape(concept["对应形式-画面"])}
\n' if concept.get("对应形式-声音"): html += f'
对应形式-声音:{html_module.escape(concept["对应形式-声音"])}
\n' html += '
\n' html += '
\n' # 抽象概念实质和形式 abstract_concepts = paragraph.get("抽象概念实质和形式", []) if abstract_concepts: html += '
\n' html += '抽象概念实质和形式:\n' for concept in abstract_concepts: concept_name = concept.get("抽象概念名称", "") html += '
\n' if concept_name: html += f'
{html_module.escape(concept_name)}
\n' if concept.get("对应形式-文案"): html += f'
对应形式-文案:{html_module.escape(concept["对应形式-文案"])}
\n' if concept.get("对应形式-画面"): html += f'
对应形式-画面:{html_module.escape(concept["对应形式-画面"])}
\n' if concept.get("对应形式-声音"): html += f'
对应形式-声音:{html_module.escape(concept["对应形式-声音"])}
\n' html += '
\n' html += '
\n' html += '
\n' html += '
\n' return html def generate_tab3_content(data: Dict[str, Any]) -> str: """生成Tab3内容:整体结构理解""" html = '\n' return html