Skip to content

Commit 4c6d14d

Browse files
committed
Add code hightlight.
1 parent 174bd8c commit 4c6d14d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@
175175
border-radius: 5px;
176176
overflow-x: auto;
177177
margin-bottom: 1rem;
178+
font-family: 'Courier New', monospace;
178179
}
179180

180181
pre code {
182+
font-family: 'Courier New', monospace;
181183
display: block;
182184
}
183185

@@ -1440,6 +1442,24 @@ <h4>More</h4>
14401442
themeToggle.textContent = '☀️';
14411443
}
14421444
}
1445+
// --- Prism code highlight for all code blocks ---
1446+
document.querySelectorAll('pre > code').forEach(function(code) {
1447+
// If no language- class, try to guess or set default
1448+
if (![...code.classList].some(cls => cls.startsWith('language-'))) {
1449+
// Guess by content or fallback to language-java
1450+
const text = code.textContent.trim();
1451+
if (text.startsWith('<dependency>') || text.startsWith('<') && text.endsWith('>')) {
1452+
code.classList.add('language-xml');
1453+
} else if (text.startsWith('#') || text.includes('=') && !text.includes(';')) {
1454+
code.classList.add('language-properties');
1455+
} else {
1456+
code.classList.add('language-java');
1457+
}
1458+
}
1459+
});
1460+
if (window.Prism && Prism.highlightAll) {
1461+
Prism.highlightAll();
1462+
}
14431463
});
14441464

14451465
const translations = {

0 commit comments

Comments
 (0)