Skip to content

Commit 4fe7195

Browse files
simonwclaude
andauthored
Add black background body tag to terminal-to-html output (#104)
Modified the terminal-to-html tool to wrap all generated HTML output in a complete HTML document with a body tag that sets the background color to black. This ensures consistent black backgrounds regardless of whether the input is RTF, HTML, or plain text. Co-authored-by: Claude <noreply@anthropic.com>
1 parent ec06a4f commit 4fe7195

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

terminal-to-html.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,20 @@ <h1>Terminal to HTML</h1>
443443
return div.innerHTML;
444444
}
445445

446+
function wrapInHtmlDocument(content) {
447+
return `<!DOCTYPE html>
448+
<html lang="en">
449+
<head>
450+
<meta charset="UTF-8">
451+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
452+
<title>Terminal Output</title>
453+
</head>
454+
<body style="background: black; margin: 0; padding: 0;">
455+
${content}
456+
</body>
457+
</html>`;
458+
}
459+
446460
function checkGithubAuth() {
447461
const token = localStorage.getItem('GITHUB_TOKEN');
448462
const authLinkContainer = document.getElementById('authLinkContainer');
@@ -570,7 +584,7 @@ <h1>Terminal to HTML</h1>
570584
if (htmlData) {
571585
// HTML is available, use it directly
572586
htmlOutput = htmlData;
573-
fullHtml = htmlData;
587+
fullHtml = wrapInHtmlDocument(htmlData);
574588
} else {
575589
// Try RTF
576590
const rtfData = clipboardData.getData('text/rtf');
@@ -593,7 +607,7 @@ <h1>Terminal to HTML</h1>
593607
if (styles.length > 0) {
594608
preStyle = ` style="${styles.join('; ')}; padding: 15px; border-radius: 4px;"`;
595609
}
596-
fullHtml = `<pre${preStyle}>${htmlOutput}</pre>`;
610+
fullHtml = wrapInHtmlDocument(`<pre${preStyle}>${htmlOutput}</pre>`);
597611
} catch (error) {
598612
resultsDiv.innerHTML = `<div class="error">Error parsing RTF: ${error.message}</div>`;
599613
return;
@@ -604,7 +618,7 @@ <h1>Terminal to HTML</h1>
604618

605619
if (plainText) {
606620
htmlOutput = escapeHtml(plainText);
607-
fullHtml = `<pre>${htmlOutput}</pre>`;
621+
fullHtml = wrapInHtmlDocument(`<pre>${htmlOutput}</pre>`);
608622
} else {
609623
resultsDiv.innerHTML = '<div class="error">No supported format detected in clipboard.</div>';
610624
return;

0 commit comments

Comments
 (0)