Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -198,24 +198,6 @@ def find_environments(latex_code):
|
|
| 198 |
|
| 199 |
return environments
|
| 200 |
|
| 201 |
-
# Define LaTeX code snippets for toolbar actions
|
| 202 |
-
latex_snippets = {
|
| 203 |
-
"bold": "\\textbf{$0}",
|
| 204 |
-
"italic": "\\textit{$0}",
|
| 205 |
-
"math_inline": "$\n$0\n$",
|
| 206 |
-
"section": "\\section{$0}",
|
| 207 |
-
"subsection": "\\subsection{$0}",
|
| 208 |
-
"itemize": "\\begin{itemize}\n\t\\item $0\n\\end{itemize}",
|
| 209 |
-
"enumerate": "\\begin{enumerate}\n\t\\item $0\n\\end{enumerate}",
|
| 210 |
-
"equation": "\\begin{equation}\n\t$0\n\\end{equation}",
|
| 211 |
-
"align": "\\begin{align}\n\t$0\n\\end{align}",
|
| 212 |
-
"figure": "\\begin{figure}[h]\n\t\\centering\n\t\\includegraphics[width=0.8\\textwidth]{$0}\n\t\\caption{Caption}\n\t\\label{fig:label}\n\\end{figure}",
|
| 213 |
-
"table": "\\begin{table}[h]\n\t\\centering\n\t\\begin{tabular}{ccc}\n\t\t$0 & B & C \\\\\n\t\t1 & 2 & 3 \\\\\n\t\\end{tabular}\n\t\\caption{Caption}\n\t\\label{tab:label}\n\\end{table}",
|
| 214 |
-
"fraction": "\\frac{$0}{denominator}",
|
| 215 |
-
"sqrt": "\\sqrt{$0}",
|
| 216 |
-
"package": "\\usepackage{$0}"
|
| 217 |
-
}
|
| 218 |
-
|
| 219 |
# Default LaTeX template
|
| 220 |
default_template = r"""\documentclass{article}
|
| 221 |
\usepackage[utf8]{inputenc}
|
|
@@ -387,35 +369,6 @@ st.markdown("""
|
|
| 387 |
font-size: 12px;
|
| 388 |
}
|
| 389 |
|
| 390 |
-
/* Toolbar */
|
| 391 |
-
.toolbar {
|
| 392 |
-
background-color: #2d2d2d;
|
| 393 |
-
padding: 5px;
|
| 394 |
-
display: flex;
|
| 395 |
-
gap: 5px;
|
| 396 |
-
align-items: center;
|
| 397 |
-
}
|
| 398 |
-
|
| 399 |
-
.toolbar-button {
|
| 400 |
-
background-color: transparent;
|
| 401 |
-
border: none;
|
| 402 |
-
color: #cccccc;
|
| 403 |
-
padding: 5px;
|
| 404 |
-
cursor: pointer;
|
| 405 |
-
border-radius: 2px;
|
| 406 |
-
}
|
| 407 |
-
|
| 408 |
-
.toolbar-button:hover {
|
| 409 |
-
background-color: #3c3c3c;
|
| 410 |
-
}
|
| 411 |
-
|
| 412 |
-
.toolbar-separator {
|
| 413 |
-
width: 1px;
|
| 414 |
-
height: 20px;
|
| 415 |
-
background-color: #555;
|
| 416 |
-
margin: 0 5px;
|
| 417 |
-
}
|
| 418 |
-
|
| 419 |
/* Terminal/console styling */
|
| 420 |
.terminal {
|
| 421 |
background-color: #1e1e1e;
|
|
@@ -725,26 +678,6 @@ def render_status_bar():
|
|
| 725 |
"""
|
| 726 |
st.markdown(status_html, unsafe_allow_html=True)
|
| 727 |
|
| 728 |
-
# VS Code-style toolbar buttons
|
| 729 |
-
def render_toolbar_buttons():
|
| 730 |
-
col1, col2, col3, col4, col5 = st.columns([1, 1, 1, 1, 5])
|
| 731 |
-
|
| 732 |
-
with col1:
|
| 733 |
-
st.button("Bold", key="btn_bold", help="Insert bold text")
|
| 734 |
-
st.button("Italic", key="btn_italic", help="Insert italic text")
|
| 735 |
-
|
| 736 |
-
with col2:
|
| 737 |
-
st.button("Section", key="btn_section", help="Insert section heading")
|
| 738 |
-
st.button("Subsection", key="btn_subsection", help="Insert subsection heading")
|
| 739 |
-
|
| 740 |
-
with col3:
|
| 741 |
-
st.button("Itemize", key="btn_itemize", help="Insert bulleted list")
|
| 742 |
-
st.button("Enumerate", key="btn_enumerate", help="Insert numbered list")
|
| 743 |
-
|
| 744 |
-
with col4:
|
| 745 |
-
st.button("Equation", key="btn_equation", help="Insert equation environment")
|
| 746 |
-
st.button("Table", key="btn_table", help="Insert table environment")
|
| 747 |
-
|
| 748 |
# Render a document outline based on section hierarchy
|
| 749 |
def render_document_outline(structure):
|
| 750 |
if not structure:
|
|
@@ -959,38 +892,6 @@ def main():
|
|
| 959 |
# Tab bar
|
| 960 |
render_editor_tabs()
|
| 961 |
|
| 962 |
-
# Toolbar buttons
|
| 963 |
-
render_toolbar_buttons()
|
| 964 |
-
|
| 965 |
-
# Check for toolbar button clicks
|
| 966 |
-
button_clicked = False
|
| 967 |
-
snippet_to_insert = ""
|
| 968 |
-
|
| 969 |
-
if st.session_state.get("btn_bold", False):
|
| 970 |
-
st.session_state.latex_code += "\\textbf{}"
|
| 971 |
-
st.rerun()
|
| 972 |
-
elif st.session_state.get("btn_italic", False):
|
| 973 |
-
st.session_state.latex_code += "\\textit{}"
|
| 974 |
-
st.rerun()
|
| 975 |
-
elif st.session_state.get("btn_section", False):
|
| 976 |
-
st.session_state.latex_code += "\\section{}"
|
| 977 |
-
st.rerun()
|
| 978 |
-
elif st.session_state.get("btn_subsection", False):
|
| 979 |
-
st.session_state.latex_code += "\\subsection{}"
|
| 980 |
-
st.rerun()
|
| 981 |
-
elif st.session_state.get("btn_itemize", False):
|
| 982 |
-
st.session_state.latex_code += "\\begin{itemize}\n \\item \n\\end{itemize}"
|
| 983 |
-
st.rerun()
|
| 984 |
-
elif st.session_state.get("btn_enumerate", False):
|
| 985 |
-
st.session_state.latex_code += "\\begin{enumerate}\n \\item \n\\end{enumerate}"
|
| 986 |
-
st.rerun()
|
| 987 |
-
elif st.session_state.get("btn_equation", False):
|
| 988 |
-
st.session_state.latex_code += "\\begin{equation}\n \n\\end{equation}"
|
| 989 |
-
st.rerun()
|
| 990 |
-
elif st.session_state.get("btn_table", False):
|
| 991 |
-
st.session_state.latex_code += "\\begin{table}[h]\n \\centering\n \\begin{tabular}{ccc}\n A & B & C \\\\\n 1 & 2 & 3 \\\\\n \\end{tabular}\n \\caption{Caption}\n \\label{tab:label}\n\\end{table}"
|
| 992 |
-
st.rerun()
|
| 993 |
-
|
| 994 |
# Editor with Monaco or fallback to text area
|
| 995 |
st.markdown('<div class="monaco-editor-container">', unsafe_allow_html=True)
|
| 996 |
|
|
|
|
| 198 |
|
| 199 |
return environments
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
# Default LaTeX template
|
| 202 |
default_template = r"""\documentclass{article}
|
| 203 |
\usepackage[utf8]{inputenc}
|
|
|
|
| 369 |
font-size: 12px;
|
| 370 |
}
|
| 371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
/* Terminal/console styling */
|
| 373 |
.terminal {
|
| 374 |
background-color: #1e1e1e;
|
|
|
|
| 678 |
"""
|
| 679 |
st.markdown(status_html, unsafe_allow_html=True)
|
| 680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
# Render a document outline based on section hierarchy
|
| 682 |
def render_document_outline(structure):
|
| 683 |
if not structure:
|
|
|
|
| 892 |
# Tab bar
|
| 893 |
render_editor_tabs()
|
| 894 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 895 |
# Editor with Monaco or fallback to text area
|
| 896 |
st.markdown('<div class="monaco-editor-container">', unsafe_allow_html=True)
|
| 897 |
|