Update app.py
Browse files
app.py
CHANGED
@@ -312,8 +312,35 @@ with st.sidebar:
|
|
312 |
render_with_bold = st.checkbox("Render with Bold Formatting (remove ** markers)", value=True, key="render_with_bold")
|
313 |
auto_bold_numbers = st.checkbox("Auto Bold Numbered Lines", value=True, key="auto_bold_numbers")
|
314 |
enlarge_numbered = st.checkbox("Enlarge Font Size for Numbered Lines", value=True, key="enlarge_numbered")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
column_options = ["Auto"] + list(range(1, 7))
|
316 |
-
num_columns = st.selectbox("Number of Columns", options=column_options,
|
|
|
317 |
num_columns = 0 if num_columns == "Auto" else int(num_columns)
|
318 |
st.info("Font size and columns adjust to fit one page.")
|
319 |
|
|
|
312 |
render_with_bold = st.checkbox("Render with Bold Formatting (remove ** markers)", value=True, key="render_with_bold")
|
313 |
auto_bold_numbers = st.checkbox("Auto Bold Numbered Lines", value=True, key="auto_bold_numbers")
|
314 |
enlarge_numbered = st.checkbox("Enlarge Font Size for Numbered Lines", value=True, key="enlarge_numbered")
|
315 |
+
# Add AutoColumns option to automatically determine column count based on line length
|
316 |
+
auto_columns = st.checkbox("AutoColumns", value=False, key="auto_columns")
|
317 |
+
|
318 |
+
# Auto-determine column count based on longest line if AutoColumns is checked
|
319 |
+
if auto_columns:
|
320 |
+
lines = edited_markdown.strip().split('\n')
|
321 |
+
longest_line_words = 0
|
322 |
+
for line in lines:
|
323 |
+
if line.strip(): # Skip empty lines
|
324 |
+
word_count = len(line.split())
|
325 |
+
longest_line_words = max(longest_line_words, word_count)
|
326 |
+
|
327 |
+
# Set recommended columns based on word count
|
328 |
+
if longest_line_words > 25:
|
329 |
+
recommended_columns = 1 # Very long lines need a single column
|
330 |
+
elif longest_line_words >= 18:
|
331 |
+
recommended_columns = 2 # Long lines need 2 columns
|
332 |
+
elif longest_line_words >= 11:
|
333 |
+
recommended_columns = 3 # Medium lines can use 3 columns
|
334 |
+
else:
|
335 |
+
recommended_columns = "Auto" # Default to auto for shorter lines
|
336 |
+
|
337 |
+
st.info(f"Longest line has {longest_line_words} words. Recommending {recommended_columns} columns.")
|
338 |
+
else:
|
339 |
+
recommended_columns = "Auto"
|
340 |
+
|
341 |
column_options = ["Auto"] + list(range(1, 7))
|
342 |
+
num_columns = st.selectbox("Number of Columns", options=column_options,
|
343 |
+
index=0 if recommended_columns == "Auto" else column_options.index(recommended_columns))
|
344 |
num_columns = 0 if num_columns == "Auto" else int(num_columns)
|
345 |
st.info("Font size and columns adjust to fit one page.")
|
346 |
|