Skip to content

Commit 678a946

Browse files
committed
feat: enhance code block styling and add automatic terminal command detection
1 parent 2fd82a6 commit 678a946

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

docs/css/main.css

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ code {
424424
}
425425

426426
pre {
427-
background-color: rgba(30, 35, 45, 0.8);
427+
background-color: #000;
428428
padding: 20px;
429429
border-radius: 5px;
430430
border: 1px solid var(--border-color);
@@ -438,8 +438,6 @@ pre {
438438

439439
/* Special styling for terminal command blocks */
440440
pre.terminal {
441-
background-color: #000;
442-
border-color: #333;
443441
border-left: 4px solid var(--highlight-color);
444442
font-family: 'Courier New', monospace;
445443
}
@@ -470,11 +468,11 @@ pre code {
470468
right: 10px;
471469
top: 10px;
472470
padding: 5px 10px;
473-
background-color: rgba(52, 152, 219, 0.3);
474-
border: 1px solid var(--highlight-color);
471+
background-color: rgba(255, 255, 255, 0.9);
472+
border: 1px solid #ccc;
475473
border-radius: 3px;
476474
cursor: pointer;
477-
color: var(--text-color);
475+
color: #000;
478476
font-size: 0.8rem;
479477
font-weight: bold;
480478
}

docs/js/main.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
// Huntarr.io Documentation JavaScript
22

33
document.addEventListener('DOMContentLoaded', function() {
4-
// Add copy functionality to code blocks
4+
// Get all code blocks
55
const codeBlocks = document.querySelectorAll('pre code');
6+
67
if (codeBlocks.length > 0) {
8+
// First pass: detect and enhance terminal command blocks
9+
codeBlocks.forEach(function(codeBlock) {
10+
const content = codeBlock.textContent.trim();
11+
const pre = codeBlock.parentNode;
12+
13+
// Detect if this is likely a terminal command (common CLI commands, starts with $, etc)
14+
const isTerminalCommand = (
15+
content.match(/^(git|npm|yarn|docker|curl|wget|cd|ls|mkdir|touch|rm|cp|mv|sudo|apt|brew)\s/) ||
16+
content.startsWith('$') ||
17+
content.includes('clone') ||
18+
content.includes('install') ||
19+
content.includes('://') && (content.includes('curl') || content.includes('wget'))
20+
);
21+
22+
if (isTerminalCommand) {
23+
// Add terminal styling to this code block
24+
pre.classList.add('terminal');
25+
26+
// If it's a single-line command, add the command prompt
27+
if (!content.includes('\n')) {
28+
codeBlock.classList.add('command-prompt');
29+
}
30+
}
31+
});
32+
33+
// Second pass: add copy functionality to all code blocks
734
codeBlocks.forEach(function(codeBlock) {
835
const copyButton = document.createElement('button');
936
copyButton.className = 'copy-button';

0 commit comments

Comments
 (0)