Spaces:
Running
Running
Update app.py
Browse filesThis should fix table alignment. The tables are supposed to be centered on the page.
462 unmodified lines463464465466467468128 unmodified lines597598599600601602462 unmodified lineschunks.append(current_chunk)return chunksdef build_html_tables(manuscript, reference, words_data):column_width_in = 1.0total_slots = 7128 unmodified lineshtml_output.append('</div>')return "".join(html_output)def generate_table_code(api_key, manuscript_name, book, chapter, verse, text_string):if not api_key:return "<p style='color:red; text-align:center;'>❌ Error: Please enter your Gemini API key.</p>", gr.update(visible=False)462 unmodified lines463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595128 unmodified lines724725726727728729730731462 unmodified lineschunks.append(current_chunk)return chunksdef build_html_tables(manuscript, reference, words_data):column_width_in = 1.0total_slots = 7total_table_width_in = 7.0# Table container locked to LTR flow with legacy centering for Docstable_style = (f"width: {total_table_width_in}in !important; min-width: {total_table_width_in}in !important; "f"max-width: {total_table_width_in}in !important; table-layout: fixed !important; ""border-collapse: collapse !important; border-spacing: 0 !important; ""direction: ltr; border: 1pt solid #b7b7b7 !important; background-color: #ffffff; ""line-height: 1.0 !important; height: auto; ""margin-top: 0 !important; margin-bottom: 0 !important; ""margin-left: auto !important; margin-right: auto !important;")base_cell = "border: 1pt solid #b7b7b7 !important; padding: 0.069in !important; height: auto; overflow: hidden; white-space: normal !important; word-wrap: break-word !important; box-sizing: border-box !important;"hebrew_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18px !important; color: #000000 !important; text-align: right !important; vertical-align: middle; padding-top: 0.069in !important; padding-bottom: 0.069in !important; padding-left: 0.069in !important; padding-right: 0.069in !important; {base_cell}"english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 11px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}"strongs_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.15 !important; {base_cell}"heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}"# Outer container explicitly forces LTR alignment so Docs will center ithtml_output = ['<div id="table-payload" class="white-canvas" dir="ltr" align="center" style="background-color: #ffffff; padding: 15px; border-radius: 8px; display: block; width: 100%; box-sizing: border-box; text-align: center; direction: ltr;">']table_chunks = calculate_clean_chunks(words_data)for idx, current_chunk in enumerate(table_chunks):# Open a new table for each chunk with align="center" and dir="ltr"html_output.append(f'<table dir="ltr" align="center" style="{table_style}" cellpadding="0" cellspacing="0">')html_output.append(' <colgroup>')for _ in range(total_slots):html_output.append(f' <col style="width: {column_width_in}in !important; min-width: {column_width_in}in !important; max-width: {column_width_in}in !important;">')html_output.append(' </colgroup>')is_first = (idx == 0)is_last_table = (idx == len(table_chunks) - 1)allocated_slots = len(current_chunk) + (1 if is_first else 0)if is_last_table:while allocated_slots < total_slots:current_chunk.append({"hebrew": " ","transliteration": " ","translation": " ","morphology": " ","strongs": " ","word_first_ot_ref": " ","root": " ","root_strongs": " ","root_first_ot_ref": " "})allocated_slots += 1# --- ROW 1: Hebrew Word Units (Right-Justified within their cells) ---html_output.append(' <tr style="height: auto; line-height: 1.0 !important;">')if is_first:html_output.append(f' <td style="{heading_cell_style}">{reference}</td>')for word in current_chunk:html_output.append(f' <td dir="rtl" style="{hebrew_cell_style}">{word.get("hebrew", " ")}</td>')html_output.append(' </tr>')# --- ROW 2: Centered English Multi-Line Stacks ---html_output.append(' <tr style="height: auto; line-height: 1.0 !important;">')if is_first:formatted_manuscript = manuscript.replace(" ", "<br>") if " " in manuscript else manuscripthtml_output.append(f' <td style="{heading_cell_style}">{formatted_manuscript}</td>')is_first = Falsefor word in current_chunk:if word.get("hebrew") != " " and word.get("hebrew") != " ":t_lit = clean_hyphens_for_docs(word.get("transliteration", ""))t_lat = clean_hyphens_for_docs(word.get("translation", ""))morph = clean_hyphens_for_docs(word.get("morphology", ""))content = f'{t_lit}<br>{t_lat}<br>{morph}'html_output.append(f' <td class="english-cell" dir="ltr" style="{english_cell_style}">{content}</td>')else:html_output.append(f' <td dir="ltr" style="{english_cell_style}"> </td>')html_output.append(' </tr>')# --- ROW 3: Strong\'s Concordance Number Links ---html_output.append(' <tr style="height: auto; line-height: 1.0 !important;">')if idx == 0:html_output.append(f' <td style="{strongs_cell_style}"></td>')for word in current_chunk:hebrew_word = word.get("hebrew", " ")if hebrew_word != " " and hebrew_word != " ":strongs_number = word.get("strongs", "NONE")word_first_ot_ref = word.get("word_first_ot_ref", "NONE")root_word = word.get("root", "NONE")root_strongs_number = word.get("root_strongs", "NONE")root_first_ot_ref = word.get("root_first_ot_ref", "NONE")strongs_root_cell = make_pealim_strongs_root_cell(strongs_number,hebrew_word,word_first_ot_ref,root_word,root_strongs_number,root_first_ot_ref)html_output.append(f' <td dir="ltr" style="{strongs_cell_style}">{strongs_root_cell}</td>')else:html_output.append(f' <td dir="ltr" style="{strongs_cell_style}"> </td>')html_output.append(' </tr>')# Close the table for this chunk and inject a small spacerhtml_output.append("</table>""<div style=\"font-family: 'Times New Roman', serif !important; ""font-size: 4pt !important; ""line-height: 4pt !important; ""height: 4pt !important; ""margin: 0 !important; ""padding: 0 !important; ""background-color: #ffffff !important;\"> </div>")html_output.append('</div>')return "".join(html_output)"""def build_html_tables(manuscript, reference, words_data):column_width_in = 1.0total_slots = 7128 unmodified lineshtml_output.append('</div>')return "".join(html_output)"""def generate_table_code(api_key, manuscript_name, book, chapter, verse, text_string):if not api_key:return "<p style='color:red; text-align:center;'>❌ Error: Please enter your Gemini API key.</p>", gr.update(visible=False)
app.py+129