Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -73,4 +73,38 @@ if uploaded_file is not None:
|
|
73 |
# for summ in summ_text:
|
74 |
# st.write(summ)
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
|
|
73 |
# for summ in summ_text:
|
74 |
# st.write(summ)
|
75 |
|
76 |
+
# Function to render HTML content
|
77 |
+
def render_html(text):
|
78 |
+
return f"<div>{text}</div>"
|
79 |
+
|
80 |
+
# Initialize session state for page index
|
81 |
+
if 'page_index' not in st.session_state:
|
82 |
+
st.session_state.page_index = 0
|
83 |
+
|
84 |
+
# Function to handle page turn
|
85 |
+
def turn_page(direction):
|
86 |
+
if direction == "next" and st.session_state.page_index < len(text_list) - 1:
|
87 |
+
st.session_state.page_index += 1
|
88 |
+
elif direction == "prev" and st.session_state.page_index > 0:
|
89 |
+
st.session_state.page_index -= 1
|
90 |
+
|
91 |
+
# Display page turner controls
|
92 |
+
col1, col2, col3 = st.columns([1, 2, 1])
|
93 |
+
with col1:
|
94 |
+
st.button("Previous", on_click=turn_page, args=("prev",))
|
95 |
+
with col3:
|
96 |
+
st.button("Next", on_click=turn_page, args=("next",))
|
97 |
+
with col2:
|
98 |
+
st.write(f"Page {st.session_state.page_index + 1} of {len(text_list)}")
|
99 |
+
|
100 |
+
# Display editable text box
|
101 |
+
text = st.text_area("Edit Text", summ_text[st.session_state.page_index], height=200)
|
102 |
+
|
103 |
+
# Display HTML box
|
104 |
+
st.markdown(render_html(text), unsafe_allow_html=True)
|
105 |
+
|
106 |
+
# Update list with edited text
|
107 |
+
text_list[st.session_state.page_index] = text
|
108 |
+
|
109 |
+
|
110 |
|