aazankhanYousafzai commited on
Commit
96f69e3
·
verified ·
1 Parent(s): b1d3b94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  st.set_page_config(
4
  page_title="Text Case Converter",
@@ -56,6 +57,19 @@ textarea {
56
  </style>
57
  """, unsafe_allow_html=True)
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  # ---------- UI ----------
60
  st.markdown("<div class='card'>", unsafe_allow_html=True)
61
 
@@ -83,10 +97,12 @@ with col2:
83
  with col3:
84
  if st.button("Toggle Case"):
85
  st.session_state["out"] = text.swapcase()
 
 
86
 
87
  if "out" in st.session_state:
88
  st.markdown("### Output")
89
  st.text_area("", st.session_state["out"], height=150)
90
 
91
  st.markdown("</div>", unsafe_allow_html=True)
92
- st.markdown("<div class='footer'>Made with ❤️ using Streamlit</div>", unsafe_allow_html=True)
 
1
  import streamlit as st
2
+ import re
3
 
4
  st.set_page_config(
5
  page_title="Text Case Converter",
 
57
  </style>
58
  """, unsafe_allow_html=True)
59
 
60
+ # ---------- Helper Function ----------
61
+ def paragraph_style(text):
62
+ sentences = re.split(r'(?<=[.!?])\s*', text.strip())
63
+ fixed = []
64
+ for s in sentences:
65
+ s = s.strip()
66
+ if not s:
67
+ continue
68
+ if not s.endswith(('.', '!', '?')):
69
+ s += '.'
70
+ fixed.append(s.capitalize())
71
+ return " ".join(fixed)
72
+
73
  # ---------- UI ----------
74
  st.markdown("<div class='card'>", unsafe_allow_html=True)
75
 
 
97
  with col3:
98
  if st.button("Toggle Case"):
99
  st.session_state["out"] = text.swapcase()
100
+ if st.button("Paragraph Style"):
101
+ st.session_state["out"] = paragraph_style(text)
102
 
103
  if "out" in st.session_state:
104
  st.markdown("### Output")
105
  st.text_area("", st.session_state["out"], height=150)
106
 
107
  st.markdown("</div>", unsafe_allow_html=True)
108
+ st.markdown("<div class='footer'>Made with ❤️ using Streamlit</div>", unsafe_allow_html=True)