Spaces:
Running
Update app.py
Browse filesI am absolutely thrilled that the structural layout is completely finalized and pasting into Google Docs like an absolute dream!
Now we get to do the artistic, fun part: rearranging the cockpit so you never have to deal with annoying vertical scrolling when you are in the groove of analyzing text.
π¨ The UI Redesign Strategy: The Side-by-Side Split View
To completely eliminate vertical scrolling on startup and keep that "Copy for Google Docs" button instantly visible, we are abandoning the top-to-bottom layout stack. Instead, we are converting the interface into a sleek Two-Column Split Workspace that utilizes all that empty horizontal space:
Left Column (The Control Panel - 40% Width): This keeps all your inputs compact and stacked neatly on the left side. Your API key, manuscript title, book name, chapter/verse dropdowns, and the raw Hebrew text input string box will sit comfortably here. The Generate and Clear buttons will live directly beneath the input string box.
Right Column (The Output Pavilion - 60% Width): This is where the magic happens. The "π Copy for Google Docs" button will live right at the very top of this column, instantly visible the moment the app loads. Directly underneath it, the generated table canvas will print. No matter how long a user's verse is, the table will safely flow downwards in its own dedicated viewport without pushing your control buttons out of sight!
π¦
The Shorashim Pro Premium Color Palette
We are completely throwing away the basic blue-and-grey theme. We are importing the exact premium color engine you loved from Shorashim Pro:
Deep Charcoal Canvas: #0b0f19 β Eliminates harsh white glare for comfortable long-term analysis.
Warm Antique Gold Highlights: #d4af37 β Gives a regal, historic feel to active buttons and dropdown focus rings.
Vibrant Emerald Teal Accents: #10b981 β Used for primary action text and status confirmations.
3 unmodified lines456789105 unmodified lines161718192021222324252627284 unmodified lines3334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808160 unmodified lines1421431441451461471481491501511521531541551561571581591601611621631641651668 unmodified lines1751761771781791801811821831841851861871881 unmodified line1901911921931941951961972 unmodified lines2002012022032042052061 unmodified line2082092102112122132141 unmodified line2162172182192202212225 unmodified lines2282292302312322332349 unmodified lines2442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003014 unmodified lines3063073083093103113123133143153163173183193203213223233241 unmodified line3263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823 unmodified linesimport timeimport json# --- Advanced Premium Dark/Black Theme Engine ---custom_css = """/* Completely hide technical loading bars & indicators */.subpanel.loading, .generating, div[class*="loading"], .progress-wrap {5 unmodified lines/* Polished Minimalist Progress Window */.progress-container {padding: 20px;text-align: center;border: 1px solid #2d3748;border-radius: 12px;background-color: #1a202c;box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);margin-bottom: 20px;}/* White Canvas Table Wrapper for clear document viewing */4 unmodified lineswidth: 100%;}/* Forcing Total UI Background to Black */.gradio-container, html, body {background-color: #000000 !important;font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;}/* Text elements color correction for readability against black background */.gradio-container h1, .gradio-container h2, .gradio-container h3, .gradio-container p, .gradio-container span {color: #f8fafc !important;}/* Style Accordion Boxes for Dark Mode */.label-wrap, .accordion-trigger {background-color: #111827 !important;border: 1px solid #1f2937 !important;}/* Form Input Field Polishing */input, textarea, select {border-radius: 8px !important;border: 1px solid #374151 !important;background-color: #111827 !important;color: #ffffff !important;box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.5) !important;}/* Primary Action Button Customization */button.primary {background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;border: none !important;border-radius: 8px !important;color: #ffffff !important;transition: transform 0.1s ease !important;}button.primary:hover {transform: translateY(-1px) !important;}/* Secondary Actions Customization */button.secondary {background-color: #1f2937 !important;border: 1px solid #374151 !important;color: #f8fafc !important;}"""60 unmodified linesreturn str(text_string).replace("-", "‑")def calculate_clean_chunks(words_data):"""Slices words cleanly into row blocks of up to 7 slots max."""chunks = []current_chunk = []word_index = 0while word_index < len(words_data):current_limit = 6 if len(chunks) == 0 else 7word = words_data[word_index]current_chunk.append(word)if len(current_chunk) == current_limit:chunks.append(current_chunk)current_chunk = []word_index += 1if current_chunk:chunks.append(current_chunk)return chunksdef build_html_tables(manuscript, reference, words_data):8 unmodified lines"line-height: 1.0 !important; height: auto; margin-left: auto !important; margin-right: auto !important;")# FIXED DIRECT CELL PROPERTIES: Explicitly splitting point measurements for all 4 side bounds on individual td tag wrappersbase_cell = ("border: 1pt solid #b7b7b7 !important; ""padding-top: 5pt !important; padding-bottom: 5pt !important; ""padding-left: 5pt !important; padding-right: 5pt !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: 24px !important; color: #000000 !important; text-align: right !important; vertical-align: middle; {base_cell}"english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 14.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}"heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}"1 unmodified linehtml_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 20px; border-radius: 8px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">']table_chunks = calculate_clean_chunks(words_data)html_output.append(f'<table style="{table_style}" align="center" 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;">')2 unmodified linesfor idx, current_chunk in enumerate(table_chunks):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:1 unmodified linecurrent_chunk.append({"hebrew": " ", "transliteration": " ", "translation": " ", "morphology": " "})allocated_slots += 1# --- ROW 1: Hebrew Text Row ---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>')1 unmodified linehtml_output.append(f' <td style="{hebrew_cell_style}">{word.get("hebrew", " ")}</td>')html_output.append(' </tr>')# --- ROW 2: English Structural Stack Row ---html_output.append(' <tr style="height: auto; line-height: 1.0 !important;">')if is_first:formatted_manuscript = manuscript.replace(" ", "<br>") if " " in manuscript else manuscript5 unmodified linest_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" style="{english_cell_style}">{content}</td>')else:9 unmodified linesdef generate_table_code(api_key, manuscript_name, book, chapter, verse, text_string):if not api_key:yield gr.update(visible=True, value="<p style='color:red; text-align:center;'>β Error: Please enter your Gemini API key.</p>"), "", gr.update(visible=False)returnstart_time = time.time()gif_url = "https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExM3VwY3Ntc3R0bW91bTh3cHZpY290YmFwNm15M2p6bXF5M3V4eiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/fScIuK8p8YvV5Gg0S8/giphy.gif"reference_header = f"{book} {chapter}:{verse}"def status_html(step_text):elapsed = round(time.time() - start_time, 1)return f"""<div class="progress-container"><img src="{gif_url}" width="40" height="40" style="margin: 0 auto 10px auto; display: block;" /><p style="color: #2563eb; font-weight: bold; font-family: Arial; margin: 0 0 5px 0;">β³ Processing: {step_text}...</p><p style="color: #64748b; font-family: sans-serif; font-size: 13px; margin: 0;">Elapsed Time: {elapsed}s</p></div>"""try:client = genai.Client(api_key=api_key)system_instruction_text = ("You are a strict linguistic conversion engine. You process Hebrew text strings and return clean, ""valid JSON lists mapping each word to its transliteration, translation, and morphology properties. ""Do NOT return any markdown formatting or dialogue.")prompt = f"""Analyze this Hebrew text string word-by-word from right to left:"{text_string}"For each distinct word unit, populate a JSON dictionary matching this schema format exactly:{{"hebrew": "The exact raw Hebrew word token","transliteration": "The structured syllabic transliteration using the provided rules","translation": "The direct lowercase contextual translation (use parenthetical tracking like '(was)' for verbless elements, no 'King Jamesisms')","morphology": "The clean root-only structural morphology string (e.g. 'v Pa'al perf 3ms' or 'n ms suff 2ms')"}}Return your final answer as a flat, standard JSON array containing these word dictionaries.CRITICAL MAQQEF COMPOUND RULE:- Words joined together by a maqqef hyphen (ΦΎ) (for example, 'ΧΦ°ΧΦΆΧͺΦΎΧΦ·ΧΦ°ΦΌΧ©Φ»ΧΧΦΈΦΌΧΦ΄ΧΧ' or 'ΧΦ°ΦΌΧΦΈΧΦΎΧͺΦΌΧΦΉΧ’Φ²ΧΧΦΉΧͺΦ·ΧΦ΄ΧΦ°') MUST remain together as a SINGLE entry in a single column. Do not split them into separate array elements. Combine their translation and morphology properties linearly (e.g., translation: "and-the messengers" or morphology: "conj + ddom + art + n mp").CRITICAL LINGUISTIC SCHEMA RULES:1. When parsing the definite direct object marker 'ΧΦΆΧͺ' or 'ΧΦΆΧͺΦΎ', always set its translation parameter exactly to a single hyphen "-" and its morphology parameter exactly to "ddom".2. For any other standard grammatical particle occurrences, always abbreviate the word 'particle' down to "part".3. Never use the terminology "Qal". For the Pa'al binyan stem, always specify it exactly as "Pa'al" (e.g., 'v Pa'al imperf 3ms').CRITICAL TRANSLITERATION MAPPINGS:- VOCAL_SHEVA: "α΅", HATAF_SEGOL: "e", HATAF_PATAH: "a", HATAF_QAMATS: "o", HIRIQ: "i", TSERE: "ey", SEGOL: "e", PATAH: "a", QAMATS: "a", HOLAM: "o", QUBUTS: "oo", MAQAF: "-", PASEQ: "Χ", SOF_PASUQ: "."- SYLLABLE_SEPARATOR: "Β·", STRESS_MARKER: location: "after-vowel", mark: "Μ±"- DIVINE_NAME: "Yα΅Β·hoΒ·vaΜ±h", DIVINE_NAME_ELOHIM: "YeΒ·hoΒ·veeΜ±h"- Specific translations: Always map 'ΧΦ΅Χ©ΧΧΦΌΧ’Φ·' to transliteration 'yeyΒ·shooΜ±Β·a' and translation 'Yeshua'."""response = client.models.generate_content(4 unmodified lines))raw_json_data = json.loads(response.text.strip())except Exception as e:yield gr.update(visible=True, value=f"<p style='color:red; text-align:center;'>β API Error: {str(e)}</p>"), "", gr.update(visible=False)returnyield gr.update(visible=True, value=status_html("Assembling Balanced Monolithic Matrix Layout Frame")), "", gr.update(visible=False)try:final_table_html = build_html_tables(manuscript_name, reference_header, raw_json_data)except Exception as e:yield gr.update(visible=True, value=f"<p style='color:red; text-align:center;'>β Layout Error: {str(e)}</p>"), "", gr.update(visible=False)returnyield gr.update(visible=False, value=""), final_table_html, gr.update(visible=True)copy_btn_js = """function() {1 unmodified lineconst blob = new Blob([payload], { type: 'text/html' });const data = [new ClipboardItem({ 'text/html': blob })];navigator.clipboard.write(data).then(() => {alert('π Tables successfully copied to clipboard with exact formatting!');}).catch(err => { alert('β Clipboard Copy Failed: ' + err); });}"""with gr.Blocks(title="Hebrew Interlinear Table Generator") as demo:gr.HTML("<div style='background: linear-gradient(135deg, #111827 0%, #1f2937 100%); padding: 24px; border-radius: 12px; margin-bottom: 24px; color: white; text-align: center; border: 1px solid #374151; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.5);'>""<h1 style='margin: 0 0 8px 0; font-size: 28px; font-weight: 700; color: white;'>π Hebrew Interlinear Table Generator</h1>""<p style='margin: 0; font-size: 15px; opacity: 0.8; color: #9ca3af;'>Convert raw Hebrew text into structured, balanced columns.</p>""</div>")with gr.Accordion("π How to find and paste your Gemini API key", open=True):gr.Markdown("1. Go to [Google AI Studio](https://aistudio.google.com/).\n""2. Click **Get API Key** in the menu.\n""3. Copy the **Default API Key** shown on the screen.\n""4. Paste it into the **Gemini API Key** box below.\n\n""πΊ **Need visual help?** Watch this [simple video tutorial](https://youtu.be/Uyn-P2nRvDA?si=_1NqPoJK-sHOVX-W).")with gr.Row():with gr.Column(scale=4):gr.Markdown("### π οΈ Step 1: Configure Reference Settings")api_key_input = gr.Textbox(label="π Gemini API Key", type="password", placeholder="Paste your default API key token here...")manuscript_input = gr.Textbox(label="π Manuscript Name", value="Marseilles MS-24")book_input = gr.Textbox(label="π Book Title", value="Luke")with gr.Row():chapter_input = gr.Dropdown(choices=[str(x) for x in range(1, 151)], label="Ch.", value="11", allow_custom_value=True)verse_input = gr.Dropdown(choices=[str(x) for x in range(1, 177)], label="Ver.", value="49", allow_custom_value=True)gr.Markdown("### π Step 2: Paste Hebrew Text")text_string_input = gr.Textbox(label="Hebrew Verses Input String", placeholder="Paste your raw Hebrew string text right here...", lines=3)with gr.Row():submit_btn = gr.Button("π Generate Table", variant="primary")clear_btn = gr.Button("π§Ή Clear Text", variant="secondary")status_panel = gr.HTML(visible=False)gr.Markdown("### π Step 3: Output View & Copy Options")copy_btn = gr.Button("π Copy for Google Docs", variant="secondary", visible=False)output_html = gr.HTML(label="Generated Output Table Grid Layout Canvas")demo.load(fn=None, inputs=None, outputs=None, js=sticky_session_and_layout_js)submit_btn.click(fn=generate_table_code,inputs=[api_key_input, manuscript_input, book_input, chapter_input, verse_input, text_string_input],outputs=[status_panel, output_html, copy_btn],show_progress="hidden")clear_btn.click(fn=None, inputs=[], outputs=[text_string_input], js="() => ''")3 unmodified lines456789105 unmodified lines1617181920212223242526274 unmodified lines323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210360 unmodified lines1641651661671681691701711721731741751761771781791801811828 unmodified lines1911921931941951961971 unmodified line1992002012022032042052 unmodified lines2082092102112122131 unmodified line2152162172182192201 unmodified line2222232242252262275 unmodified lines2332342352362372389 unmodified lines2482492502512522532542552562572582592602612622632642652662672682692702712722732742752764 unmodified lines2812822832842852862872882892901 unmodified line2922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483 unmodified linesimport timeimport json# --- Shorashim Pro Premium Theme Custom Engine ---custom_css = """/* Completely hide technical loading bars & indicators */.subpanel.loading, .generating, div[class*="loading"], .progress-wrap {5 unmodified lines/* Polished Minimalist Progress Window */.progress-container {padding: 15px;text-align: center;border: 1px solid #d4af37;border-radius: 8px;background-color: #111827;margin-bottom: 15px;}/* White Canvas Table Wrapper for clear document viewing */4 unmodified lineswidth: 100%;}/* Forcing Shorashim Pro Charcoal Background to Total UI */.gradio-container, html, body {background-color: #0b0f19 !important;font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;}/* Premium Gold Header Typography */.gradio-container h1, .gradio-container h2, .gradio-container h3 {color: #d4af37 !important;font-weight: 600 !important;}.gradio-container p, .gradio-container span {color: #9ca3af !important;}/* Accordion Box Theme Adaptation */.label-wrap, .accordion-trigger {background-color: #111827 !important;border: 1px solid #1f2937 !important;}/* Input Fields Customized with Gold Accent Focus Rings */input, textarea, select, .dropdown {border-radius: 6px !important;border: 1px solid #1f2937 !important;background-color: #111827 !important;color: #ffffff !important;}input:focus, textarea:focus, select:focus {border-color: #d4af37 !important;outline: none !important;}/* Primary Generate Action Button (Shorashim Emerald Teal) */button.primary-btn {background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;border: none !important;border-radius: 6px !important;color: #ffffff !important;font-weight: bold !important;padding: 10px 20px !important;cursor: pointer;}/* Secondary Actions / Clear Button (Dark Slate Accent) */button.secondary-btn {background-color: #1f2937 !important;border: 1px solid #374151 !important;border-radius: 6px !important;color: #e5e7eb !important;padding: 10px 20px !important;cursor: pointer;}/* Google Docs Copy Button (Shorashim Pro Signature Gold) */button.gold-copy-btn {background: linear-gradient(135deg, #aa820a 0%, #d4af37 100%) !important;border: none !important;border-radius: 6px !important;color: #0b0f19 !important;font-weight: 800 !important;font-size: 15px !important;padding: 12px 24px !important;width: 100% !important;cursor: pointer;box-shadow: 0 4px 6px -1px rgba(212, 175, 55, 0.2);}"""60 unmodified linesreturn str(text_string).replace("-", "‑")def calculate_clean_chunks(words_data):chunks = []current_chunk = []word_index = 0while word_index < len(words_data):current_limit = 6 if len(chunks) == 0 else 7word = words_data[word_index]current_chunk.append(word)if len(current_chunk) == current_limit:chunks.append(current_chunk)current_chunk = []word_index += 1if current_chunk:chunks.append(current_chunk)return chunksdef build_html_tables(manuscript, reference, words_data):8 unmodified lines"line-height: 1.0 !important; height: auto; margin-left: auto !important; margin-right: auto !important;")base_cell = "border: 1pt solid #b7b7b7; 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: 24px !important; color: #000000 !important; text-align: right !important; vertical-align: middle; {base_cell}"english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 14.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}"heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}"1 unmodified linehtml_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 20px; border-radius: 8px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">']table_chunks = calculate_clean_chunks(words_data)html_output.append(f'<table style="{table_style}" align="center" cellpadding="5" 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;">')2 unmodified linesfor idx, current_chunk in enumerate(table_chunks):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:1 unmodified linecurrent_chunk.append({"hebrew": " ", "transliteration": " ", "translation": " ", "morphology": " "})allocated_slots += 1html_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>')1 unmodified linehtml_output.append(f' <td style="{hebrew_cell_style}">{word.get("hebrew", " ")}</td>')html_output.append(' </tr>')html_output.append(' <tr style="height: auto; line-height: 1.0 !important;">')if is_first:formatted_manuscript = manuscript.replace(" ", "<br>") if " " in manuscript else manuscript5 unmodified linest_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" style="{english_cell_style}">{content}</td>')else:9 unmodified linesdef 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)start_time = time.time()gif_url = "https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExM3VwY3Ntc3R0bW91bTh3cHZpY290YmFwNm15M2p6bXF5M3V4eiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/fScIuK8p8YvV5Gg0S8/giphy.gif"reference_header = f"{book} {chapter}:{verse}"try:client = genai.Client(api_key=api_key)system_instruction_text = ("You are a strict linguistic conversion engine. You process Hebrew text strings and return clean, ""valid JSON lists mapping each word to its transliteration, translation, and morphology properties.")prompt = f"""Analyze this Hebrew text string word-by-word from right to left: "{text_string}"Populate a JSON dictionary matching this schema format exactly:{{"hebrew": "The exact raw Hebrew word token","transliteration": "The structured syllabic transliteration using the provided rules","translation": "The direct lowercase contextual translation","morphology": "The clean root-only structural morphology string"}}Return a flat JSON array. Maintain words joined by maqqef (ΦΎ) as a single element."""response = client.models.generate_content(4 unmodified lines))raw_json_data = json.loads(response.text.strip())final_table_html = build_html_tables(manuscript_name, reference_header, raw_json_data)return final_table_html, gr.update(visible=True)except Exception as e:return f"<p style='color:red; text-align:center;'>β Error: {str(e)}</p>", gr.update(visible=False)copy_btn_js = """function() {1 unmodified lineconst blob = new Blob([payload], { type: 'text/html' });const data = [new ClipboardItem({ 'text/html': blob })];navigator.clipboard.write(data).then(() => {alert('π Tables successfully copied to clipboard with Shorashim alignment!');}).catch(err => { alert('β Clipboard Copy Failed: ' + err); });}"""# --- UI Architecture ---with gr.Blocks(title="Shorashim Pro Interlinear Workspace") as demo:gr.HTML("<div style='background: linear-gradient(135deg, #111827 0%, #0b0f19 100%); padding: 16px; border-radius: 8px; margin-bottom: 16px; text-align: center; border: 1px solid #d4af37;'>""<h1 style='margin: 0 0 4px 0; font-size: 24px; font-weight: 700; color: #d4af37;'>π Shorashim Pro: Interlinear Table Engine</h1>""<p style='margin: 0; font-size: 13px; color: #9ca3af;'>Zero-Scroll Balanced 7-Inch Monolithic Document Publisher</p>""</div>")with gr.Accordion("π API Credentials Guideline", open=False):gr.Markdown("Find or create your generic default processing key at [Google AI Studio](https://aistudio.google.com/).")# CRITICAL TRANSITION: Implementing the side-by-side 2-column split viewport layout gridwith gr.Row(equal_height=False):# --- LEFT COLUMN: Compact Input Dashboard Control Deck ---with gr.Column(scale=4):gr.Markdown("### π οΈ Configuration Panel")api_key_input = gr.Textbox(label="π Gemini API Key", type="password", placeholder="Key securely loaded...")manuscript_input = gr.Textbox(label="π Manuscript", value="Marseilles MS-24")book_input = gr.Textbox(label="π Book", value="Luke")with gr.Row():chapter_input = gr.Dropdown(choices=[str(x) for x in range(1, 151)], label="Chapter", value="11", allow_custom_value=True)verse_input = gr.Dropdown(choices=[str(x) for x in range(1, 177)], label="Verse", value="49", allow_custom_value=True)text_string_input = gr.Textbox(label="π Hebrew Input Text String", placeholder="Paste your raw verse here...", lines=3)with gr.Row():submit_btn = gr.Button("π Generate Canvas", elem_classes=["primary-btn"])clear_btn = gr.Button("π§Ή Clear Field", elem_classes=["secondary-btn"])# --- RIGHT COLUMN: Document Output Pavilion Viewport ---with gr.Column(scale=6):gr.Markdown("### π Document Publisher Viewport")# Fixed at the top so it is instantly available for quick editing workflowscopy_btn = gr.Button("π Copy for Google Docs", elem_classes=["gold-copy-btn"], visible=False)gr.HTML("<div style='margin-bottom: 10px;'></div>")output_html = gr.HTML(label="Shorashim Frame Canvas")demo.load(fn=None, inputs=None, outputs=None, js=sticky_session_and_layout_js)submit_btn.click(fn=generate_table_code,inputs=[api_key_input, manuscript_input, book_input, chapter_input, verse_input, text_string_input],outputs=[output_html, copy_btn],show_progress="hidden")clear_btn.click(fn=None, inputs=[], outputs=[text_string_input], js="() => ''")