Spaces:
Build error
Build error
Update app.py
Browse files19 unmodified lines202122232425262728293031323334353637383940414243441 unmodified line46474849505152535455565758596061136 unmodified lines19819920020120220320420559 unmodified lines2652662672682692702712722732742752762772782792802812822832842852862872882892902911 unmodified line29329429529629729829989 unmodified lines38939039139239339439518 unmodified lines41441541641741841942011 unmodified lines4324334344354364374382 unmodified lines4414424434444454464477 unmodified lines45545645745845946046112 unmodified lines47447547647747847948048148248348414 unmodified lines49950050150250350450531 unmodified lines53753853954054154254320 unmodified lines56456556656756856957022 unmodified lines59359459559659759859920 unmodified lines62062162262362462562614 unmodified lines6416426436446456466471 unmodified line64965065165265365465511 unmodified lines66766866967067167267367467567667767867968068168268358 unmodified lines74274374474574674774827 unmodified lines77677777877978078178278378478578678778878974 unmodified lines8648658668678688698702 unmodified lines87387487587687787887988088188215 unmodified lines8988999009019029039048 unmodified lines9139149159169179189199209219229239249259269279289299302 unmodified lines9339349359369379389399407 unmodified lines9489499509519529539549551 unmodified line9579589599609619629639649659669679689694 unmodified lines9749759769779789799802 unmodified lines9839849859869879889895 unmodified lines9959969979989991000100113 unmodified lines101510161017101810191020102120 unmodified lines104210431044104510461047104817 unmodified lines106610671068106910701071107210731074107510761077107819 unmodified lines# Set page configurationst.set_page_config(page_title="Professional LaTeX Editor",page_icon="📝",layout="wide",initial_sidebar_state="collapsed")# Check if pdflatex is availabledef is_pdflatex_installed():return shutil.which("pdflatex") is not None# Function to convert LaTeX to PDFdef latex_to_pdf(latex_code):# Check if pdflatex is installedif not is_pdflatex_installed():st.error("pdflatex not found. Debug info:")st.code(f"PATH: {os.environ.get('PATH')}")result = subprocess.run(["which", "pdflatex"], capture_output=True, text=True)st.code(f"which pdflatex: {result.stdout} {result.stderr}")return None, "", "Error: pdflatex is not installed or not in PATH."with tempfile.TemporaryDirectory() as temp_dir:temp_path = Path(temp_dir)1 unmodified linepdf_file = temp_path / "document.pdf"# Write LaTeX code to filewith open(tex_file, "w") as f:f.write(latex_code)try:# Run pdflatex to compile the LaTeX fileprocess = subprocess.run(["pdflatex", "-interaction=nonstopmode", "-output-directory", temp_dir, str(tex_file)],capture_output=True,text=True)# Check if PDF was createdif pdf_file.exists():136 unmodified linesreturn environments# Default LaTeX templatedefault_template = r"""\documentclass{article}\usepackage[utf8]{inputenc}\usepackage{amsmath}\usepackage{amssymb}59 unmodified lines\label{tab:simple}\end{table}\section{Figures}You can include figures using the following syntax:% \begin{figure}[h]% \centering% \includegraphics[width=0.7\textwidth]{example-image}% \caption{Example figure}% \label{fig:example}% \end{figure}\section{Citations}You can cite references using the \verb|\cite{}| command \cite{example}.\section{Cross-References}You can reference sections, figures, and tables using the \verb|\ref{}| command.For example, see Table~\ref{tab:simple}.\section{Conclusion}Your conclusion here.% Sample bibliography entry\begin{thebibliography}{9}\bibitem{example} Author, A. (2023). \textit{Title of the Work}. Publisher.\end{thebibliography}1 unmodified line\end{document}"""# Enhanced VSCode-like stylingst.markdown("""<style>/* Base theming - VS Code inspired */89 unmodified linescolor: #cca700;}/* Outline view */.outline-view {background-color: #252526;border: 1px solid #2d2d2d;18 unmodified linesmargin-left: 5px;}/* Download button styling */.download-button {display: inline-block;padding: 8px 16px;11 unmodified linesbackground-color: #4eb772;}/* PDF preview area */.preview-container {background-color: #252526;border: 1px solid #2d2d2d;2 unmodified linesmargin-top: 10px;}/* Control panel */.control-panel {background-color: #252526;border: 1px solid #2d2d2d;7 unmodified linesgap: 5px;}/* Messages */.stInfo {background-color: #063b49;color: #bbbbbb;12 unmodified linesborder: 1px solid #1e5a3a;}/* Hide Streamlit footer and menu */footer, header {display: none !important;}#MainMenu {visibility: hidden;}/* Custom tabs */.stTabs [data-baseweb="tab-list"] {background-color: #2d2d2d;gap: 0px !important;14 unmodified linescolor: white;}/* Problems panel */.problems-panel {background-color: #252526;border: 1px solid #2d2d2d;31 unmodified linesmargin-top: 2px;}/* Document info panel */.document-info {background-color: #252526;border: 1px solid #2d2d2d;20 unmodified linestext-align: right;}/* Packages panel */.packages-panel {background-color: #252526;border: 1px solid #2d2d2d;22 unmodified linesfont-family: monospace;}/* Environment analyzer */.environments-panel {background-color: #252526;border: 1px solid #2d2d2d;20 unmodified linesfont-weight: bold;}/* Simple keyboard shortcut */.shortcut-item {background-color: #252526;border: 1px solid #2d2d2d;14 unmodified linesmargin-right: 10px;}/* Monaco editor container */.monaco-editor-container {border: 1px solid #2d2d2d;border-radius: 4px;1 unmodified linemargin-bottom: 10px;}/* Make sure Monaco editor has correct background */.monaco-editor, .monaco-editor-background, .monaco-editor .margin {background-color: #1e1e1e !important;}11 unmodified lines"""st.markdown(tab_html, unsafe_allow_html=True)# VS Code-style status bardef render_status_bar():status_html = """<div class="status-bar"><span>LaTeX</span><span>Line: 1, Col: 1</span><span>UTF-8</span></div>"""st.markdown(status_html, unsafe_allow_html=True)# Render a document outline based on section hierarchydef render_document_outline(structure):if not structure:58 unmodified linesst.markdown('</div>', unsafe_allow_html=True)# Render document information paneldef render_document_info(latex_code):# Ensure latex_code is a stringif not isinstance(latex_code, str):try:27 unmodified linesref_count = len(re.findall(r'\\ref\{', latex_code))cite_count = len(re.findall(r'\\cite\{', latex_code))# Render the info panelst.markdown('<div class="document-info">', unsafe_allow_html=True)info_rows = [("Document Class", doc_class),("Word Count", word_count),("Character Count", char_count),("Line Count", line_count),("Equations", equation_count),("Align Environments", align_count),("Figures", figure_count),74 unmodified linesdef main():# Initialize session stateif 'latex_code' not in st.session_state:st.session_state.latex_code = default_templateif 'show_preview' not in st.session_state:st.session_state.show_preview = Falseif 'last_compiled' not in st.session_state:2 unmodified linesst.session_state.errors = []if 'warnings' not in st.session_state:st.session_state.warnings = []# Check installation statusif not is_pdflatex_installed():st.warning("⚠️ LaTeX is not installed. The compilation feature will not work.")# Create main layoutcol1, col2 = st.columns([3, 2])15 unmodified linesif MONACO_AVAILABLE:try:# Try to use Monaco editor with minimal parameterslatex_code = st_monaco(st.session_state.latex_code, height=500)if latex_code is not None:st.session_state.latex_code = latex_codeexcept Exception as e:8 unmodified linesst.markdown('</div>', unsafe_allow_html=True)# Status barrender_status_bar()st.markdown('</div>', unsafe_allow_html=True)# F5 shortcut reminderrender_f5_shortcut()# Control buttons with VS Code stylingst.markdown('<div class="button-group">', unsafe_allow_html=True)compile_btn = st.button("Compile", help="Compile LaTeX to PDF (F5)")load_template_btn = st.button("Load Template", help="Load default template")clear_btn = st.button("Clear", help="Clear editor content")st.markdown('</div>', unsafe_allow_html=True)2 unmodified linesst.session_state.compile_clicked = Truest.session_state.last_compiled = time.time()if load_template_btn:st.session_state.latex_code = default_templatest.rerun()if clear_btn:7 unmodified linescol_a, col_b = st.columns(2)with col_a:st.checkbox("Auto-compile on save", value=False, key="auto_compile")st.checkbox("Use pdflatex", value=True, key="use_pdflatex")st.checkbox("Enable BibTeX", value=False, key="use_bibtex")st.checkbox("Show line numbers", value=True, key="show_line_numbers")1 unmodified linest.selectbox("Document Class",["article", "report", "book", "letter", "beamer"],index=0, key="doc_class")st.selectbox("PDF Engine",["pdflatex", "xelatex", "lualatex"],index=0, key="pdf_engine")st.selectbox("Editor Theme",["Dark", "Light", "High Contrast"],index=0, key="editor_theme")st.markdown('</div>', unsafe_allow_html=True)with col2:4 unmodified lines# PDF compilation and outputif 'compile_clicked' in st.session_state and st.session_state.compile_clicked:with st.spinner("Compiling..."):pdf_data, stdout, stderr = latex_to_pdf(st.session_state.latex_code)# Parse errors and warningserrors, warnings = parse_latex_errors(stdout + stderr)2 unmodified linesif pdf_data:st.session_state.pdf_data = pdf_datast.success("Compilation successful")# Toggle button for previewif st.button("Toggle Preview", help="Show or hide the PDF preview"):5 unmodified lines# Display compilation infoif st.session_state.last_compiled:time_str = time.strftime("%H:%M:%S", time.localtime(st.session_state.last_compiled))st.info(f"Last compiled: {time_str}")# Optional previewif st.session_state.show_preview:13 unmodified linesst.session_state.compile_clicked = Falseelse:st.error("Compilation failed")st.markdown('<div class="terminal">', unsafe_allow_html=True)# Highlight errors in output20 unmodified lines# Display compilation infoif st.session_state.last_compiled:time_str = time.strftime("%H:%M:%S", time.localtime(st.session_state.last_compiled))st.info(f"Last compiled: {time_str}")# Optional previewif st.session_state.show_preview:17 unmodified linesif structure:render_document_outline(structure)else:st.info("No document structure detected. Add sections using the toolbar.")with output_tabs[2]:# Document analysis features# Document inforender_document_info(st.session_state.latex_code)# Package analysispackages = analyze_packages(st.session_state.latex_code)19 unmodified lines2021222324252627282930313233343536373839404142434445464748491 unmodified line5152535455565758596061626364656667686970136 unmodified lines20720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132259 unmodified lines3823833843853863873883893901 unmodified line39239339439539639739889 unmodified lines48848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252318 unmodified lines54254354454554654711 unmodified lines5595605615625635642 unmodified lines5675685695705715727 unmodified lines58058158258358458512 unmodified lines59859960060160260360460560614 unmodified lines62162262362462562631 unmodified lines65865966066166266320 unmodified lines68468568668768868922 unmodified lines71271371471571671720 unmodified lines73873974074174274314 unmodified lines7587597607617627631 unmodified line76576676776876977011 unmodified lines78278378478578678778878979079179279379479579679779879980080180280380480580680780880981081158 unmodified lines87087187287387487587627 unmodified lines90490590690790890991091191291391491591691791891992092192274 unmodified lines99799899910001001100210032 unmodified lines100610071008100910101011101210131014101510161017101810191020102115 unmodified lines10371038103910401041104210438 unmodified lines10521053105410551056105710581059106010611062106310641065106610671068106910701071107210732 unmodified lines1076107710781079108010811082108310841085108610877 unmodified lines109510961097109810991100110111021103110411051106110711081109111011111 unmodified line11131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611374 unmodified lines11421143114411451146114711482 unmodified lines11511152115311541155115611575 unmodified lines116311641165116611671168116913 unmodified lines118311841185118611871188118920 unmodified lines121012111212121312141215121617 unmodified lines123412351236123712381239124012411242124312441245124619 unmodified lines# Set page configurationst.set_page_config(page_title="Professional LaTeX Editor with Chinese Support",page_icon="📝",layout="wide",initial_sidebar_state="collapsed")# Check if LaTeX engines are availabledef check_latex_engines():engines = {'pdflatex': shutil.which("pdflatex") is not None,'xelatex': shutil.which("xelatex") is not None,'lualatex': shutil.which("lualatex") is not None}return engines# Function to convert LaTeX to PDF with engine selectiondef latex_to_pdf(latex_code, engine='xelatex'):# Check if the specified engine is installedif not shutil.which(engine):st.error(f"{engine} not found. Debug info:")st.code(f"PATH: {os.environ.get('PATH')}")result = subprocess.run(["which", engine], capture_output=True, text=True)st.code(f"which {engine}: {result.stdout} {result.stderr}")return None, "", f"Error: {engine} is not installed or not in PATH."with tempfile.TemporaryDirectory() as temp_dir:temp_path = Path(temp_dir)1 unmodified linepdf_file = temp_path / "document.pdf"# Write LaTeX code to filewith open(tex_file, "w", encoding='utf-8') as f:f.write(latex_code)try:# Different compilation arguments for different enginesif engine == 'xelatex':cmd = ["xelatex", "-interaction=nonstopmode", "-output-directory", temp_dir, str(tex_file)]elif engine == 'lualatex':cmd = ["lualatex", "-interaction=nonstopmode", "-output-directory", temp_dir, str(tex_file)]else: # pdflatexcmd = ["pdflatex", "-interaction=nonstopmode", "-output-directory", temp_dir, str(tex_file)]# Run LaTeX engine to compile the fileprocess = subprocess.run(cmd, capture_output=True, text=True)# Check if PDF was createdif pdf_file.exists():136 unmodified linesreturn environments# Default LaTeX template with Chinese supportdefault_template_chinese = r"""\documentclass{article}\usepackage{xeCJK}\usepackage{amsmath}\usepackage{amssymb}\usepackage{graphicx}\usepackage{hyperref}\usepackage{xcolor}\usepackage{geometry}% Set Chinese fonts (using Noto fonts available in the container)\setCJKmainfont{Noto Serif CJK SC}\setCJKsansfont{Noto Sans CJK SC}\setCJKmonofont{Noto Sans Mono CJK SC}% Page geometry\geometry{a4paper, margin=1in}\title{中文LaTeX文档示例}\author{作者姓名}\date{\today}\begin{document}\maketitle\section{简介}这是一个支持中文的LaTeX文档示例。您可以在这里编写中文内容。This document also supports English text seamlessly mixed with Chinese characters.\section{数学表达式}\subsection{方程式}著名的爱因斯坦质能方程:\begin{equation}E = mc^2\end{equation}二次方程求解公式:\begin{equation}x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\end{equation}\subsection{微积分}积分示例:\begin{equation}\int_{0}^{\pi} \sin(x) \, dx = 2\end{equation}\section{列表和项目}\subsection{无序列表}\begin{itemize}\item 第一项包含\textbf{粗体文字}\item 第二项包含\textit{斜体文字}\item 第三项包含\textcolor{blue}{彩色文字}\end{itemize}\subsection{有序列表}\begin{enumerate}\item 第一步\item 第二步\item 第三步\end{enumerate}\section{表格}\begin{table}[h]\centering\begin{tabular}{|c|c|c|}\hline姓名 & 年龄 & 城市 \\\hline张三 & 25 & 北京 \\\hline李四 & 30 & 上海 \\\hline\end{tabular}\caption{简单表格示例}\label{tab:simple}\end{table}\section{图形}您可以使用以下语法包含图形:% \begin{figure}[h]% \centering% \includegraphics[width=0.7\textwidth]{example-image}% \caption{示例图形}% \label{fig:example}% \end{figure}\section{引用文献}您可以使用 \verb|\cite{}| 命令引用参考文献 \cite{example}。\section{交叉引用}您可以使用 \verb|\ref{}| 命令引用章节、图形和表格。例如,参见表格~\ref{tab:simple}。\section{结论}这里是您的结论。% 示例参考文献条目\begin{thebibliography}{9}\bibitem{example} 作者姓名 (2023). \textit{书籍标题}. 出版社.\end{thebibliography}\end{document}"""# Default LaTeX template (English)default_template_english = r"""\documentclass{article}\usepackage[utf8]{inputenc}\usepackage{amsmath}\usepackage{amssymb}59 unmodified lines\label{tab:simple}\end{table}\section{Conclusion}Your conclusion here.\begin{thebibliography}{9}\bibitem{example} Author, A. (2023). \textit{Title of the Work}. Publisher.\end{thebibliography}1 unmodified line\end{document}"""# Enhanced VSCode-like styling (keeping the original styling)st.markdown("""<style>/* Base theming - VS Code inspired */89 unmodified linescolor: #cca700;}/* Engine status indicators */.engine-status {display: flex;gap: 10px;margin: 10px 0;padding: 10px;background-color: #252526;border-radius: 4px;}.engine-item {display: flex;align-items: center;gap: 5px;padding: 5px 10px;border-radius: 3px;font-size: 12px;}.engine-available {background-color: #1e3a1e;color: #4caf50;}.engine-unavailable {background-color: #3a1e1e;color: #f44336;}/* All other existing styles remain the same */.outline-view {background-color: #252526;border: 1px solid #2d2d2d;18 unmodified linesmargin-left: 5px;}.download-button {display: inline-block;padding: 8px 16px;11 unmodified linesbackground-color: #4eb772;}.preview-container {background-color: #252526;border: 1px solid #2d2d2d;2 unmodified linesmargin-top: 10px;}.control-panel {background-color: #252526;border: 1px solid #2d2d2d;7 unmodified linesgap: 5px;}.stInfo {background-color: #063b49;color: #bbbbbb;12 unmodified linesborder: 1px solid #1e5a3a;}footer, header {display: none !important;}#MainMenu {visibility: hidden;}.stTabs [data-baseweb="tab-list"] {background-color: #2d2d2d;gap: 0px !important;14 unmodified linescolor: white;}.problems-panel {background-color: #252526;border: 1px solid #2d2d2d;31 unmodified linesmargin-top: 2px;}.document-info {background-color: #252526;border: 1px solid #2d2d2d;20 unmodified linestext-align: right;}.packages-panel {background-color: #252526;border: 1px solid #2d2d2d;22 unmodified linesfont-family: monospace;}.environments-panel {background-color: #252526;border: 1px solid #2d2d2d;20 unmodified linesfont-weight: bold;}.shortcut-item {background-color: #252526;border: 1px solid #2d2d2d;14 unmodified linesmargin-right: 10px;}.monaco-editor-container {border: 1px solid #2d2d2d;border-radius: 4px;1 unmodified linemargin-bottom: 10px;}.monaco-editor, .monaco-editor-background, .monaco-editor .margin {background-color: #1e1e1e !important;}11 unmodified lines"""st.markdown(tab_html, unsafe_allow_html=True)# VS Code-style status bar with engine infodef render_status_bar(engine="XeLaTeX"):status_html = f"""<div class="status-bar"><span>{engine}</span><span>Line: 1, Col: 1</span><span>UTF-8</span></div>"""st.markdown(status_html, unsafe_allow_html=True)# Render engine statusdef render_engine_status():engines = check_latex_engines()engine_html = '<div class="engine-status">'for engine_name, available in engines.items():status_class = "engine-available" if available else "engine-unavailable"status_icon = "✅" if available else "❌"engine_html += f'<div class="engine-item {status_class}">{status_icon} {engine_name}</div>'engine_html += '</div>'st.markdown(engine_html, unsafe_allow_html=True)# Render a document outline based on section hierarchydef render_document_outline(structure):if not structure:58 unmodified linesst.markdown('</div>', unsafe_allow_html=True)# Render document information paneldef render_document_info(latex_code, engine):# Ensure latex_code is a stringif not isinstance(latex_code, str):try:27 unmodified linesref_count = len(re.findall(r'\\ref\{', latex_code))cite_count = len(re.findall(r'\\cite\{', latex_code))# Check for Chinese characterschinese_chars = len(re.findall(r'[\u4e00-\u9fff]', latex_code))# Render the info panelst.markdown('<div class="document-info">', unsafe_allow_html=True)info_rows = [("LaTeX Engine", engine),("Document Class", doc_class),("Word Count", word_count),("Character Count", char_count),("Line Count", line_count),("Chinese Characters", chinese_chars),("Equations", equation_count),("Align Environments", align_count),("Figures", figure_count),74 unmodified linesdef main():# Initialize session stateif 'latex_code' not in st.session_state:st.session_state.latex_code = default_template_chineseif 'show_preview' not in st.session_state:st.session_state.show_preview = Falseif 'last_compiled' not in st.session_state:2 unmodified linesst.session_state.errors = []if 'warnings' not in st.session_state:st.session_state.warnings = []if 'selected_engine' not in st.session_state:st.session_state.selected_engine = 'xelatex'# Check available enginesengines = check_latex_engines()available_engines = [engine for engine, available in engines.items() if available]if not available_engines:st.error("⚠️ No LaTeX engines are installed. The compilation feature will not work.")return# Create main layoutcol1, col2 = st.columns([3, 2])15 unmodified linesif MONACO_AVAILABLE:try:# Try to use Monaco editor with minimal parameterslatex_code = st_monaco(st.session_state.latex_code, height=500, language="latex")if latex_code is not None:st.session_state.latex_code = latex_codeexcept Exception as e:8 unmodified linesst.markdown('</div>', unsafe_allow_html=True)# Status bar with engine inforender_status_bar(st.session_state.selected_engine.upper())st.markdown('</div>', unsafe_allow_html=True)# Engine status displayrender_engine_status()# F5 shortcut reminderrender_f5_shortcut()# Control buttons with VS Code stylingst.markdown('<div class="button-group">', unsafe_allow_html=True)compile_btn = st.button("Compile", help="Compile LaTeX to PDF (F5)")load_chinese_btn = st.button("Load Chinese Template", help="Load Chinese template")load_english_btn = st.button("Load English Template", help="Load English template")clear_btn = st.button("Clear", help="Clear editor content")st.markdown('</div>', unsafe_allow_html=True)2 unmodified linesst.session_state.compile_clicked = Truest.session_state.last_compiled = time.time()if load_chinese_btn:st.session_state.latex_code = default_template_chinesest.rerun()if load_english_btn:st.session_state.latex_code = default_template_englishst.rerun()if clear_btn:7 unmodified linescol_a, col_b = st.columns(2)with col_a:# Engine selectionif available_engines:selected_engine = st.selectbox("LaTeX Engine",available_engines,index=available_engines.index(st.session_state.selected_engine) if st.session_state.selected_engine in available_engines else 0,key="engine_select")st.session_state.selected_engine = selected_enginest.checkbox("Auto-compile on save", value=False, key="auto_compile")st.checkbox("Enable BibTeX", value=False, key="use_bibtex")st.checkbox("Show line numbers", value=True, key="show_line_numbers")1 unmodified linest.selectbox("Document Class",["article", "report", "book", "letter", "beamer"],index=0, key="doc_class")st.selectbox("Font Selection",["Noto CJK (Chinese)", "WQY (Chinese)", "Latin Modern (English)", "Times (English)"],index=0, key="font_selection")st.selectbox("Editor Theme",["Dark", "Light", "High Contrast"],index=0, key="editor_theme")# Engine informationst.markdown("### Engine Information")engine_info = {'pdflatex': 'Traditional LaTeX engine, good for English documents','xelatex': 'Modern engine with Unicode support, excellent for Chinese and mixed languages','lualatex': 'Advanced engine with Lua scripting support, good for complex typography'}for engine, description in engine_info.items():status = "✅ Available" if engines.get(engine, False) else "❌ Not Available"st.write(f"**{engine.upper()}**: {description} - {status}")st.markdown('</div>', unsafe_allow_html=True)with col2:4 unmodified lines# PDF compilation and outputif 'compile_clicked' in st.session_state and st.session_state.compile_clicked:with st.spinner("Compiling..."):pdf_data, stdout, stderr = latex_to_pdf(st.session_state.latex_code, st.session_state.selected_engine)# Parse errors and warningserrors, warnings = parse_latex_errors(stdout + stderr)2 unmodified linesif pdf_data:st.session_state.pdf_data = pdf_datast.success(f"Compilation successful using {st.session_state.selected_engine.upper()}")# Toggle button for previewif st.button("Toggle Preview", help="Show or hide the PDF preview"):5 unmodified lines# Display compilation infoif st.session_state.last_compiled:time_str = time.strftime("%H:%M:%S", time.localtime(st.session_state.last_compiled))st.info(f"Last compiled: {time_str} with {st.session_state.selected_engine.upper()}")# Optional previewif st.session_state.show_preview:13 unmodified linesst.session_state.compile_clicked = Falseelse:st.error(f"Compilation failed with {st.session_state.selected_engine.upper()}")st.markdown('<div class="terminal">', unsafe_allow_html=True)# Highlight errors in output20 unmodified lines# Display compilation infoif st.session_state.last_compiled:time_str = time.strftime("%H:%M:%S", time.localtime(st.session_state.last_compiled))st.info(f"Last compiled: {time_str} with {st.session_state.selected_engine.upper()}")# Optional previewif st.session_state.show_preview:17 unmodified linesif structure:render_document_outline(structure)else:st.info("No document structure detected. Add sections using \\section{}, \\subsection{}, etc.")with output_tabs[2]:# Document analysis features# Document inforender_document_info(st.session_state.latex_code, st.session_state.selected_engine.upper())# Package analysispackages = analyze_packages(st.session_state.latex_code)
app.py+248-80