import streamlit as st import re st.set_page_config( page_title="Text Case Converter", layout="centered", ) # ---------- Cool Tech Theme ---------- st.markdown(""" """, unsafe_allow_html=True) # ---------- Helper Function ---------- def paragraph_style(text): sentences = re.split(r'(?<=[.!?])\s*', text.strip()) fixed = [] for s in sentences: s = s.strip() if not s: continue if not s.endswith(('.', '!', '?')): s += '.' fixed.append(s.capitalize()) return " ".join(fixed) # ---------- UI ---------- st.markdown("
", unsafe_allow_html=True) st.markdown("

Text Case Converter

", unsafe_allow_html=True) st.markdown("

Change your text instantly

", unsafe_allow_html=True) text = st.text_area("", placeholder="Type or paste your text here...", height=180) st.markdown("### Choose Conversion") col1, col2, col3 = st.columns(3) with col1: if st.button("UPPERCASE"): st.session_state["out"] = text.upper() if st.button("lowercase"): st.session_state["out"] = text.lower() with col2: if st.button("Title Case"): st.session_state["out"] = text.title() if st.button("Sentence Case"): st.session_state["out"] = text.capitalize() with col3: if st.button("Toggle Case"): st.session_state["out"] = text.swapcase() if st.button("Paragraph Style"): st.session_state["out"] = paragraph_style(text) if "out" in st.session_state: st.markdown("### Output") st.text_area("", st.session_state["out"], height=150) st.markdown("
", unsafe_allow_html=True) st.markdown("", unsafe_allow_html=True)