Skip to content

Commit 514c20d

Browse files
author
OpenClaw Sync
committed
Add code block styling: dark theme, syntax highlighting, overflow handling
1 parent e8062e7 commit 514c20d

1 file changed

Lines changed: 94 additions & 2 deletions

File tree

assets/css/main.css

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,104 @@ main {
328328
color: #3f4652;
329329
}
330330

331+
/* Inline code */
331332
.post-content code {
332-
padding: 0.1rem 0.35rem;
333+
padding: 0.15rem 0.4rem;
333334
border: 1px solid #d2d8e1;
335+
border-radius: 3px;
334336
background: #f3f6fa;
335337
font-family: "IBM Plex Mono", monospace;
336-
font-size: 0.9em;
338+
font-size: 0.88em;
339+
}
340+
341+
/* Fenced code blocks */
342+
.post-content pre {
343+
margin: 1.25rem 0;
344+
padding: 1.1rem 1.25rem;
345+
border: 1px solid #d2d8e1;
346+
border-radius: var(--radius);
347+
background: #1a1e2a;
348+
color: #d4dae6;
349+
overflow-x: auto;
350+
-webkit-overflow-scrolling: touch;
351+
line-height: 1.55;
352+
}
353+
354+
.post-content pre code {
355+
padding: 0;
356+
border: none;
357+
border-radius: 0;
358+
background: none;
359+
color: inherit;
360+
font-size: 0.85em;
361+
line-height: inherit;
362+
}
363+
364+
/* Rouge syntax highlighting (dark theme) */
365+
.highlight { background: #1a1e2a; }
366+
.highlight .c,
367+
.highlight .cm,
368+
.highlight .c1,
369+
.highlight .cs { color: #636d83; font-style: italic; } /* comments */
370+
.highlight .k,
371+
.highlight .kd,
372+
.highlight .kn,
373+
.highlight .kp,
374+
.highlight .kr,
375+
.highlight .kt { color: #c678dd; } /* keywords */
376+
.highlight .s,
377+
.highlight .s1,
378+
.highlight .s2,
379+
.highlight .sb,
380+
.highlight .sc,
381+
.highlight .sh,
382+
.highlight .sx { color: #98c379; } /* strings */
383+
.highlight .na { color: #e5c07b; } /* attribute names */
384+
.highlight .nb,
385+
.highlight .bp { color: #61afef; } /* builtins */
386+
.highlight .nf,
387+
.highlight .nx { color: #61afef; } /* functions */
388+
.highlight .nn { color: #e5c07b; } /* namespace */
389+
.highlight .no { color: #d19a66; } /* constants */
390+
.highlight .ni { color: #d4dae6; } /* entities */
391+
.highlight .ne { color: #e06c75; } /* exceptions */
392+
.highlight .nv,
393+
.highlight .vi,
394+
.highlight .vc,
395+
.highlight .vg,
396+
.highlight .vm { color: #e06c75; } /* variables */
397+
.highlight .o,
398+
.highlight .ow { color: #56b6c2; } /* operators */
399+
.highlight .m,
400+
.highlight .mi,
401+
.highlight .mf,
402+
.highlight .mh,
403+
.highlight .mo { color: #d19a66; } /* numbers */
404+
.highlight .p { color: #abb2bf; } /* punctuation */
405+
.highlight .gd { color: #e06c75; } /* diff deleted */
406+
.highlight .gi { color: #98c379; } /* diff inserted */
407+
408+
/* Copy-friendly: select all text in code block on triple-click */
409+
.post-content pre {
410+
user-select: all;
411+
-webkit-user-select: all;
412+
}
413+
414+
.post-content pre code {
415+
user-select: text;
416+
-webkit-user-select: text;
417+
}
418+
419+
/* Highlight wrapper from Rouge */
420+
.post-content div.highlight {
421+
margin: 1.25rem 0;
422+
border-radius: var(--radius);
423+
overflow: hidden;
424+
}
425+
426+
.post-content div.highlight pre {
427+
margin: 0;
428+
border-radius: 0;
337429
}
338430

339431
.more-posts {

0 commit comments

Comments
 (0)