Spaces:
Running
Running
Update app.py
Browse filesTHIS IS THE ONE I finally fixed cell padding.
Now on to interface design
111 unmodified lines11211311411511611511611711811912012111811912012112212512312412512612712812812913013112913013113213313413513613713813913313414014114214314413813914514614714814918 unmodified lines16816917016417117217316817417517633 unmodified lines21021121220821321421521611 unmodified lines228229230226227231232233234235111 unmodified lines
def get_minimum_column_width_in(word_dict, is_reference_block=False, ref_text="", ms_text=""): """ Measures character lengths to establish the minimum width in inches needed to hold content cleanly on a single line without wrapping. Finds the absolute longest single word token in a cell to establish the wrapping safety layout width, factoring in your 0.069in side borders. """ char_width_in = 0.072 hebrew_char_width_in = 0.140 # Precise padding safety buffer: 0.069 inches on both sides = 0.138 inches char_width_in = 0.076 hebrew_char_width_in = 0.145 padding_buffer_in = 0.069 * 2 if is_reference_block: max_chars = max(len(ref_text), len(ms_text)) # Reference blocks can split naturally on spaces (e.g., 'Luke' vs '12:3') ref_tokens = ref_text.split(" ") ms_tokens = ms_text.split(" ") max_chars = max([len(t) for t in (ref_tokens + ms_tokens)] + [5]) return (max_chars * char_width_in) + padding_buffer_in w_hebrew = len(word_dict.get("hebrew", "")) * hebrew_char_width_in w_translit = len(word_dict.get("transliteration", "")) * char_width_in w_trans = len(word_dict.get("translation", "")) * char_width_in w_morph = len(word_dict.get("morphology", "")) * char_width_in # Split each multi-word text string by spaces to find the single longest unbroken word token hebrew_tokens = word_dict.get("hebrew", "").split(" ") translit_tokens = word_dict.get("transliteration", "").split(" ") translation_tokens = word_dict.get("translation", "").split(" ") morph_tokens = word_dict.get("morphology", "").split(" ") max_w_hebrew = max([len(t) for t in hebrew_tokens]) * hebrew_char_width_in max_w_translit = max([len(t) for t in translit_tokens]) * char_width_in max_w_trans = max([len(t) for t in translation_tokens]) * char_width_in max_w_morph = max([len(t) for t in morph_tokens]) * char_width_in max_content_width = max(w_hebrew, w_translit, w_trans, w_morph) return max(max_content_width, 0.65) + padding_buffer_in longest_single_token_width = max(max_w_hebrew, max_w_translit, max_w_trans, max_w_morph) return max(longest_single_token_width, 0.60) + padding_buffer_in
def calculate_recursive_table_chunks(words_data, reference, manuscript): """ ESSENTIAL PROCEDURE: Groups words. If a 7-column layout requires more than 7.0 inches to prevent wrapping, the last word drops down recursively. Groups your text words. If a single unbroken word token causes a column footprint to exceed 7.0 inches total, the last word drops recursively. """ total_allowed_width_in = 7.0 final_row_chunks = []18 unmodified lines total_required_row_width = sum(minimum_widths) # If the combined row width fits comfortably inside 7 inches, we break and lock it if total_required_row_width <= total_allowed_width_in: break # If it exceeds 7 inches, drop the last word to the next row pool current_row_words.pop() final_row_chunks.append(current_row_words)33 unmodified lines current_chunk.append({"hebrew": " ", "transliteration": " ", "translation": " ", "morphology": " "}) slot_minimums.append(0.75)
# Proportional balancing math ensures all columns total exactly 7.0 inches overall # Proportional balancing math safely distributes space up to exactly 7.0 inches overall total_minimum_score = sum(slot_minimums) calculated_widths = [] for min_w in slot_minimums:11 unmodified lines html_output.append(f' <col style="width: {c_width}in !important; min-width: {c_width}in !important; max-width: {c_width}in !important;">') html_output.append(' </colgroup>') # Symmetrical cell padding exactly 0.069in on all 4 sides with wrap suppressed safely base_cell = "border: 1pt solid #b7b7b7; padding: 0.069in !important; height: auto; overflow: hidden; white-space: nowrap !important; box-sizing: border-box !important;" # FIXED LOGIC: white-space flipped back to normal to allow soft phrase breaks at spaces, while break-word prevents middle-word splits 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; 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; 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; vertical-align: middle; line-height: 1.0 !important; {base_cell}"app.py+25-20