mirror of
https://github.com/plexguide/Huntarr-Sonarr.git
synced 2025-12-16 20:04:16 -06:00
feat: enhance code block styling and add automatic terminal command detection
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user