jdesiree commited on
Commit
d590525
·
verified ·
1 Parent(s): 81947ec

Added MathJax for LaTeX rendering

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -444,6 +444,32 @@ custom_css = """
444
 
445
  # Create the interface with proper structure
446
  with gr.Blocks(css=custom_css, title="EduBot") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  # Title Section
448
  gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
449
 
 
444
 
445
  # Create the interface with proper structure
446
  with gr.Blocks(css=custom_css, title="EduBot") as demo:
447
+ # Add MathJax for LaTeX rendering
448
+ gr.HTML('<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>')
449
+ gr.HTML('<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>')
450
+ gr.HTML('''
451
+ <script>
452
+ window.MathJax = {
453
+ tex: {
454
+ inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],
455
+ displayMath: [['$$', '$$'], ['\\\\[', '\\\\]']],
456
+ packages: {'[+]': ['ams']}
457
+ },
458
+ svg: {fontCache: 'global'},
459
+ startup: {
460
+ ready: () => {
461
+ MathJax.startup.defaultReady();
462
+ // Re-render math when new content is added
463
+ const observer = new MutationObserver(function(mutations) {
464
+ MathJax.typesetPromise();
465
+ });
466
+ observer.observe(document.body, {childList: true, subtree: true});
467
+ }
468
+ }
469
+ };
470
+ </script>
471
+ ''')
472
+
473
  # Title Section
474
  gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
475