Keldos commited on
Commit
ab5870b
1 Parent(s): 1c0a00b

适配gradio代码块样式

Browse files
Files changed (2) hide show
  1. assets/custom.css +23 -14
  2. modules/presets.py +2 -0
assets/custom.css CHANGED
@@ -405,28 +405,37 @@ thead th {
405
  padding: .5em .2em;
406
  }
407
  /* 行内代码 */
408
- code {
409
  display: inline;
410
  white-space: break-spaces;
 
411
  border-radius: 6px;
412
  margin: 0 2px 0 2px;
413
  padding: .2em .4em .1em .4em;
414
  background-color: rgba(175,184,193,0.2);
415
  }
416
  /* 代码块 */
417
- pre code {
418
- display: block;
419
- overflow: auto;
420
- white-space: pre;
421
- /* padding: 1.4em 1.2em 0em 1.4em; */
422
- /* margin: 0.6em 2em 1em 0.2em; */
423
- color: #FFF;
 
 
 
 
424
  }
425
- .message pre {
426
- padding: 0 !important;
 
 
427
  }
428
-
429
- .gradio-container-3-32-0 code[class*=language-], .gradio-container-3-32-0 pre[class*=language-] {
430
- text-shadow: none;
431
- background-color: var(--neutral-950) !important;
432
  }
 
 
 
 
 
405
  padding: .5em .2em;
406
  }
407
  /* 行内代码 */
408
+ .message :not(pre) code {
409
  display: inline;
410
  white-space: break-spaces;
411
+ font-family: var(--font-mono);
412
  border-radius: 6px;
413
  margin: 0 2px 0 2px;
414
  padding: .2em .4em .1em .4em;
415
  background-color: rgba(175,184,193,0.2);
416
  }
417
  /* 代码块 */
418
+ .message pre,
419
+ .message pre[class^=language-] {
420
+ color: #fff;
421
+ margin: .8em 1em 1em 0em !important;
422
+ padding: var(--spacing-xl) 1.2em !important;
423
+ border-radius: var(--radius-lg) !important;
424
+ }
425
+ .message pre code,
426
+ .message pre code[class^=language-] {
427
+ text-shadow: none;
428
+ font-family: var(--font-mono);
429
  }
430
+ /* 覆盖 gradio 丑陋的复制按钮样式 */
431
+ pre button[title="copy"] {
432
+ border-radius: 5px;
433
+ transition: background-color .2s ease;
434
  }
435
+ pre button[title="copy"]:hover {
436
+ background-color: #333232;
 
 
437
  }
438
+ pre button .check {
439
+ color: #fff !important;
440
+ background: var(--neutral-950) !important;
441
+ }
modules/presets.py CHANGED
@@ -238,4 +238,6 @@ small_and_beautiful_theme = gr.themes.Soft(
238
  block_title_background_fill_dark="*primary_900",
239
  block_label_background_fill_dark="*primary_900",
240
  input_background_fill="#F6F6F6",
 
 
241
  )
 
238
  block_title_background_fill_dark="*primary_900",
239
  block_label_background_fill_dark="*primary_900",
240
  input_background_fill="#F6F6F6",
241
+ chatbot_code_background_color="*neutral_950",
242
+ chatbot_code_background_color_dark="*neutral_950",
243
  )