Molbap HF Staff commited on
Commit
514d471
Β·
verified Β·
1 Parent(s): dd6a0b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -400,11 +400,12 @@ def build_image(filename):
400
  def build_d3_graph():
401
  with gr.Group():
402
  gr.Markdown("### πŸ”— Interactive Model Dependency Graph")
403
- html_file = Path("static/d3_dependency_graph.html")
404
- if html_file.exists():
405
  gr.HTML(
406
- f"""
407
  <iframe src="file=static/d3_dependency_graph.html"
 
408
  style="width:100%;height:640px;border:1px solid #e2e8f0;border-radius:8px"
409
  loading="lazy"></iframe>
410
  """
@@ -448,6 +449,19 @@ HLJS = """
448
  mo.observe(document.body, {subtree: true, childList: true});
449
  })();
450
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  """
452
 
453
 
@@ -486,8 +500,9 @@ html, body, .gradio-container { background: #fff !important; }
486
  .gradio-container .gr-html,
487
  .gradio-container .gr-html * {
488
  opacity: 1 !important;
489
- color: var(--body-text-color) !important;
490
  }
 
 
491
 
492
  /* Scope article typography */
493
  .article { max-width: 72ch; margin: 0 auto; }
@@ -518,16 +533,15 @@ html, body, .gradio-container { background: #fff !important; }
518
  .hljs { background: transparent !important; }
519
 
520
  /* Tenets highlight: any list item that contains an anchor id gets a card look */
521
- .article ol > li:has(> a[id]) {
522
  border-left: 4px solid #1d4ed8;
523
  background: #f8fafc;
524
  padding: .75rem 1rem;
525
  margin: .5rem 0;
526
  border-radius: 8px;
527
  }
528
- .article ol > li:has(> a[id])::marker { color: #1d4ed8; font-weight: 700; }
529
- .article ol > li:has(> a[id]) code { background: #e0e7ff !important; }
530
-
531
 
532
 
533
  /* Blockquotes, images, rules */
 
400
  def build_d3_graph():
401
  with gr.Group():
402
  gr.Markdown("### πŸ”— Interactive Model Dependency Graph")
403
+ fp = Path("static/d3_dependency_graph.html")
404
+ if fp.exists():
405
  gr.HTML(
406
+ """
407
  <iframe src="file=static/d3_dependency_graph.html"
408
+ sandbox="allow-scripts allow-same-origin"
409
  style="width:100%;height:640px;border:1px solid #e2e8f0;border-radius:8px"
410
  loading="lazy"></iframe>
411
  """
 
449
  mo.observe(document.body, {subtree: true, childList: true});
450
  })();
451
  </script>
452
+ <script>
453
+ (function(){
454
+ function highlightAll() {
455
+ document.querySelectorAll('pre code').forEach((el) => { hljs.highlightElement(el); });
456
+ document.querySelectorAll('.article ol > li').forEach((li) => {
457
+ if (li.querySelector(':scope > a[id]')) li.classList.add('tenet');
458
+ });
459
+ }
460
+ highlightAll();
461
+ new MutationObserver(highlightAll).observe(document.body, {subtree: true, childList: true});
462
+ })();
463
+ </script>
464
+
465
  """
466
 
467
 
 
500
  .gradio-container .gr-html,
501
  .gradio-container .gr-html * {
502
  opacity: 1 !important;
 
503
  }
504
+ /* scope body text color to prose only */
505
+ .article { color: var(--body-text-color); }
506
 
507
  /* Scope article typography */
508
  .article { max-width: 72ch; margin: 0 auto; }
 
533
  .hljs { background: transparent !important; }
534
 
535
  /* Tenets highlight: any list item that contains an anchor id gets a card look */
536
+ .article ol > li.tenet {
537
  border-left: 4px solid #1d4ed8;
538
  background: #f8fafc;
539
  padding: .75rem 1rem;
540
  margin: .5rem 0;
541
  border-radius: 8px;
542
  }
543
+ .article ol > li.tenet::marker { color: #1d4ed8; font-weight: 700; }
544
+ .article ol > li.tenet code { background: #e0e7ff !important; }
 
545
 
546
 
547
  /* Blockquotes, images, rules */