euler314 commited on
Commit
3564d4f
·
verified ·
1 Parent(s): 34f2fda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -123
app.py CHANGED
@@ -903,120 +903,6 @@ def render_f5_shortcut():
903
  unsafe_allow_html=True
904
  )
905
 
906
- # Define LaTeX language for Monaco editor
907
- def get_latex_language_definition():
908
- return {
909
- "defaultToken": "",
910
- "tokenPostfix": ".tex",
911
- "ignoreCase": True,
912
-
913
- "brackets": [
914
- { "token": "delimiter.curly", "open": "{", "close": "}" },
915
- { "token": "delimiter.square", "open": "[", "close": "]" },
916
- { "token": "delimiter.parenthesis", "open": "(", "close": ")" }
917
- ],
918
-
919
- "keywords": [
920
- "documentclass", "usepackage", "begin", "end", "section", "subsection",
921
- "subsubsection", "chapter", "paragraph", "subparagraph", "part", "appendix",
922
- "maketitle", "tableofcontents", "figure", "table", "equation", "align",
923
- "itemize", "enumerate", "description", "center", "verbatim", "minipage",
924
- "textbf", "textit", "texttt", "textrm", "textsc", "textsf", "emph", "cite",
925
- "ref", "label", "caption", "includegraphics", "input", "include", "hline",
926
- "vspace", "hspace", "newpage", "clearpage", "pagebreak", "newcommand",
927
- "renewcommand", "providecommand", "newenvironment", "renewenvironment",
928
- "provideenvironment", "newtheorem", "footnote", "item", "multicolumn"
929
- ],
930
-
931
- "operators": [
932
- "&", "_", "^", "~", "'", "\"", "`"
933
- ],
934
-
935
- "tokenizer": {
936
- "root": [
937
- [/\\([a-zA-Z]+)/, {
938
- cases: {
939
- "@keywords": { token: "keyword.$1" },
940
- "@default": "keyword"
941
- }
942
- }],
943
- [/\{/, "delimiter.curly"],
944
- [/\}/, "delimiter.curly"],
945
- [/\[/, "delimiter.square"],
946
- [/\]/, "delimiter.square"],
947
- [/\(/, "delimiter.parenthesis"],
948
- [/\)/, "delimiter.parenthesis"],
949
- [/\$\$/, { token: "delimiter.dollar", next: "@math_block" }],
950
- [/\$/, { token: "delimiter.dollar", next: "@math_inline" }],
951
- [/%.*$/, "comment"],
952
- [/[^\\{}\[\]$%&_\^~'"` ]+/, ""]
953
- ],
954
-
955
- "math_block": [
956
- [/\$\$/, { token: "delimiter.dollar", next: "@pop" }],
957
- [/[^\\$]+/, "predefined.mathematical"],
958
- [/\\[a-zA-Z]+/, "predefined.mathematical"],
959
- [/[\\$]/, "predefined.mathematical"]
960
- ],
961
-
962
- "math_inline": [
963
- [/\$/, { token: "delimiter.dollar", next: "@pop" }],
964
- [/[^\\$]+/, "predefined.mathematical"],
965
- [/\\[a-zA-Z]+/, "predefined.mathematical"],
966
- [/[\\$]/, "predefined.mathematical"]
967
- ]
968
- }
969
- }
970
-
971
- # Define LaTeX autocompletion suggestions for Monaco editor
972
- def get_latex_completions():
973
- return [
974
- # Document structure
975
- {"label": "\\documentclass", "kind": 14, "insertText": "\\documentclass{${1:article}}", "documentation": "Defines the document class"},
976
- {"label": "\\usepackage", "kind": 14, "insertText": "\\usepackage{${1:package}}", "documentation": "Imports a package"},
977
- {"label": "\\begin", "kind": 14, "insertText": "\\begin{${1:environment}}\n\t$0\n\\end{$1}", "documentation": "Creates an environment"},
978
- {"label": "\\end", "kind": 14, "insertText": "\\end{${1:environment}}", "documentation": "Ends an environment"},
979
-
980
- # Sections
981
- {"label": "\\section", "kind": 14, "insertText": "\\section{${1:title}}", "documentation": "Creates a section"},
982
- {"label": "\\subsection", "kind": 14, "insertText": "\\subsection{${1:title}}", "documentation": "Creates a subsection"},
983
- {"label": "\\subsubsection", "kind": 14, "insertText": "\\subsubsection{${1:title}}", "documentation": "Creates a subsubsection"},
984
-
985
- # Formatting
986
- {"label": "\\textbf", "kind": 14, "insertText": "\\textbf{${1:text}}", "documentation": "Makes text bold"},
987
- {"label": "\\textit", "kind": 14, "insertText": "\\textit{${1:text}}", "documentation": "Makes text italic"},
988
- {"label": "\\underline", "kind": 14, "insertText": "\\underline{${1:text}}", "documentation": "Underlines text"},
989
- {"label": "\\emph", "kind": 14, "insertText": "\\emph{${1:text}}", "documentation": "Emphasizes text"},
990
-
991
- # Math
992
- {"label": "\\begin{equation}", "kind": 14, "insertText": "\\begin{equation}\n\t${1}\n\\end{equation}", "documentation": "Creates an equation environment"},
993
- {"label": "\\begin{align}", "kind": 14, "insertText": "\\begin{align}\n\t${1}\n\\end{align}", "documentation": "Creates an align environment"},
994
- {"label": "\\frac", "kind": 14, "insertText": "\\frac{${1:numerator}}{${2:denominator}}", "documentation": "Creates a fraction"},
995
- {"label": "\\sqrt", "kind": 14, "insertText": "\\sqrt{${1:expression}}", "documentation": "Creates a square root"},
996
- {"label": "\\sum", "kind": 14, "insertText": "\\sum_{${1:lower}}^{${2:upper}}", "documentation": "Creates a summation"},
997
- {"label": "\\int", "kind": 14, "insertText": "\\int_{${1:lower}}^{${2:upper}}", "documentation": "Creates an integral"},
998
-
999
- # Lists
1000
- {"label": "\\begin{itemize}", "kind": 14, "insertText": "\\begin{itemize}\n\t\\item ${1}\n\\end{itemize}", "documentation": "Creates a bulleted list"},
1001
- {"label": "\\begin{enumerate}", "kind": 14, "insertText": "\\begin{enumerate}\n\t\\item ${1}\n\\end{enumerate}", "documentation": "Creates a numbered list"},
1002
- {"label": "\\item", "kind": 14, "insertText": "\\item ${1}", "documentation": "Creates a list item"},
1003
-
1004
- # Tables
1005
- {"label": "\\begin{table}", "kind": 14, "insertText": "\\begin{table}[${1:h}]\n\t\\centering\n\t\\begin{tabular}{${2:ccc}}\n\t\t${3}\n\t\\end{tabular}\n\t\\caption{${4:caption}}\n\t\\label{tab:${5:label}}\n\\end{table}", "documentation": "Creates a table environment"},
1006
-
1007
- # Figures
1008
- {"label": "\\begin{figure}", "kind": 14, "insertText": "\\begin{figure}[${1:h}]\n\t\\centering\n\t\\includegraphics[width=${2:0.8}\\textwidth]{${3:filename}}\n\t\\caption{${4:caption}}\n\t\\label{fig:${5:label}}\n\\end{figure}", "documentation": "Creates a figure environment"},
1009
-
1010
- # Common environments
1011
- {"label": "\\begin{center}", "kind": 14, "insertText": "\\begin{center}\n\t${1}\n\\end{center}", "documentation": "Creates centered text"},
1012
- {"label": "\\begin{verbatim}", "kind": 14, "insertText": "\\begin{verbatim}\n${1}\n\\end{verbatim}", "documentation": "Creates verbatim text"},
1013
-
1014
- # References
1015
- {"label": "\\label", "kind": 14, "insertText": "\\label{${1:label}}", "documentation": "Creates a label for cross-referencing"},
1016
- {"label": "\\ref", "kind": 14, "insertText": "\\ref{${1:label}}", "documentation": "References a label"},
1017
- {"label": "\\cite", "kind": 14, "insertText": "\\cite{${1:key}}", "documentation": "Cites a reference"}
1018
- ]
1019
-
1020
  # Main application
1021
  def main():
1022
  # Initialize session state
@@ -1084,10 +970,6 @@ def main():
1084
  # Monaco Editor with LaTeX configuration
1085
  st.markdown('<div class="monaco-editor-container">', unsafe_allow_html=True)
1086
 
1087
- # Define LaTeX language configuration for Monaco
1088
- latex_language = get_latex_language_definition()
1089
- latex_completions = get_latex_completions()
1090
-
1091
  # Create Monaco editor component
1092
  latex_code = st_monaco(
1093
  value=st.session_state.latex_code,
@@ -1103,14 +985,10 @@ def main():
1103
  "fontSize": 14,
1104
  "wordWrap": "on",
1105
  "automaticLayout": True,
1106
- "suggestOnTriggerCharacters": True,
1107
  "quickSuggestions": True,
1108
  "snippetSuggestions": "inline",
1109
  "folding": True,
1110
- "bracketPairColorization.enabled": True,
1111
- "renderWhitespace": "boundary"
1112
- },
1113
- key="monaco_editor"
1114
  )
1115
 
1116
  st.markdown('</div>', unsafe_allow_html=True)
 
903
  unsafe_allow_html=True
904
  )
905
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
906
  # Main application
907
  def main():
908
  # Initialize session state
 
970
  # Monaco Editor with LaTeX configuration
971
  st.markdown('<div class="monaco-editor-container">', unsafe_allow_html=True)
972
 
 
 
 
 
973
  # Create Monaco editor component
974
  latex_code = st_monaco(
975
  value=st.session_state.latex_code,
 
985
  "fontSize": 14,
986
  "wordWrap": "on",
987
  "automaticLayout": True,
 
988
  "quickSuggestions": True,
989
  "snippetSuggestions": "inline",
990
  "folding": True,
991
+ }
 
 
 
992
  )
993
 
994
  st.markdown('</div>', unsafe_allow_html=True)