Skip to content

Commit a45474b

Browse files
committed
feat: add word wrapping and styling for code blocks in dark mode
1 parent 119a074 commit a45474b

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Web/Pages/Shared/_Layout.cshtml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@
8080
.navbar .nav-link {
8181
color: var(--navbar-text) !important;
8282
}
83+
84+
/* Code block styling with word wrapping */
85+
pre {
86+
white-space: pre-wrap; /* CSS3 */
87+
word-wrap: break-word; /* IE */
88+
word-break: break-word;
89+
overflow-wrap: break-word;
90+
max-width: 100%;
91+
overflow-x: hidden !important;
92+
}
93+
94+
pre code {
95+
white-space: pre-wrap !important;
96+
}
8397
</style>
8498

8599
<!-- Feeds and Sitemap -->

Web/wwwroot/css/site.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,4 +722,37 @@ html[data-theme-resolved="dark"] .tip-content table.comparison-table tbody td:la
722722
background-color: var(--primary-dark);
723723
border-color: var(--primary-dark);
724724
box-shadow: 0 0 0 0.25rem rgba(98, 0, 238, 0.25);
725+
}
726+
727+
/* Code block styling with word wrapping */
728+
pre {
729+
white-space: pre-wrap; /* CSS3 */
730+
word-wrap: break-word; /* IE */
731+
word-break: break-word;
732+
overflow-wrap: break-word;
733+
max-width: 100%;
734+
overflow-x: hidden !important;
735+
padding: 1rem;
736+
border-radius: 0.5rem;
737+
margin: 1.5rem 0;
738+
}
739+
740+
pre code {
741+
white-space: pre-wrap !important;
742+
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
743+
}
744+
745+
/* Adjust the code block styling for different screen sizes */
746+
@media (max-width: 768px) {
747+
pre {
748+
padding: 0.75rem;
749+
font-size: 0.85rem;
750+
}
751+
}
752+
753+
/* Ensure code blocks have proper background in dark mode */
754+
html[data-theme="dark"] pre,
755+
html[data-theme-resolved="dark"] pre {
756+
background-color: var(--code-bg);
757+
border: 1px solid var(--border-color);
725758
}

0 commit comments

Comments
 (0)