From 678a9467d153ffdd67df2d92302bbe6024706c1b Mon Sep 17 00:00:00 2001 From: Admin9705 <9705@duck.com> Date: Sun, 18 May 2025 15:58:27 -0400 Subject: [PATCH] feat: enhance code block styling and add automatic terminal command detection --- docs/css/main.css | 10 ++++------ docs/js/main.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/docs/css/main.css b/docs/css/main.css index b57d26c2..2c873dd9 100644 --- a/docs/css/main.css +++ b/docs/css/main.css @@ -424,7 +424,7 @@ code { } pre { - background-color: rgba(30, 35, 45, 0.8); + background-color: #000; padding: 20px; border-radius: 5px; border: 1px solid var(--border-color); @@ -438,8 +438,6 @@ pre { /* Special styling for terminal command blocks */ pre.terminal { - background-color: #000; - border-color: #333; border-left: 4px solid var(--highlight-color); font-family: 'Courier New', monospace; } @@ -470,11 +468,11 @@ pre code { right: 10px; top: 10px; padding: 5px 10px; - background-color: rgba(52, 152, 219, 0.3); - border: 1px solid var(--highlight-color); + background-color: rgba(255, 255, 255, 0.9); + border: 1px solid #ccc; border-radius: 3px; cursor: pointer; - color: var(--text-color); + color: #000; font-size: 0.8rem; font-weight: bold; } diff --git a/docs/js/main.js b/docs/js/main.js index c6271927..b25eabb5 100644 --- a/docs/js/main.js +++ b/docs/js/main.js @@ -1,9 +1,36 @@ // Huntarr.io Documentation JavaScript document.addEventListener('DOMContentLoaded', function() { - // Add copy functionality to code blocks + // Get all code blocks const codeBlocks = document.querySelectorAll('pre code'); + if (codeBlocks.length > 0) { + // First pass: detect and enhance terminal command blocks + codeBlocks.forEach(function(codeBlock) { + const content = codeBlock.textContent.trim(); + const pre = codeBlock.parentNode; + + // Detect if this is likely a terminal command (common CLI commands, starts with $, etc) + const isTerminalCommand = ( + content.match(/^(git|npm|yarn|docker|curl|wget|cd|ls|mkdir|touch|rm|cp|mv|sudo|apt|brew)\s/) || + content.startsWith('$') || + content.includes('clone') || + content.includes('install') || + content.includes('://') && (content.includes('curl') || content.includes('wget')) + ); + + if (isTerminalCommand) { + // Add terminal styling to this code block + pre.classList.add('terminal'); + + // If it's a single-line command, add the command prompt + if (!content.includes('\n')) { + codeBlock.classList.add('command-prompt'); + } + } + }); + + // Second pass: add copy functionality to all code blocks codeBlocks.forEach(function(codeBlock) { const copyButton = document.createElement('button'); copyButton.className = 'copy-button';