Created
January 23, 2025 06:52
-
-
Save scheler/0f9360487959aabba0951838d21b4825 to your computer and use it in GitHub Desktop.
splunk_fy.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>ANSI to HTML</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
background-color: #f9f9f9; | |
margin: 0; | |
padding: 20px; | |
} | |
.output { | |
font-family: monospace; | |
background-color: #f0f0f0; /* Light grey background */ | |
color: #333; | |
padding: 20px; | |
border-radius: 10px; | |
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | |
line-height: 1.6; | |
border: 1px solid #ddd; | |
white-space: pre; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="terminal-output" class="output"></div> | |
<script> | |
function ansiToHtml(ansiText) { | |
// ANSI color code mappings to corresponding HTML styles | |
const ansiStyles = { | |
'[1;32m': '<span style="color:#32CD32">', // green | |
'[1;34m': '<span style="color:#1E90FF">', // blue | |
'[1;33m': '<span style="color:#000000">', // black (replacing yellow) | |
'[0;35m': '<span style="color:#9370DB">', // purple (for FY25) | |
'[1;35m': '<span style="color:#9370DB">', // purple (for FY26) | |
'[1;31m': '<span style="color:#FF4500">', // red | |
'[0;36m': '<span style="color:#00CED1">', // cyan | |
'[1;37m': '<span style="color:#333">', // dark gray | |
'[0m': '</span>' // reset/close tag | |
}; | |
// Replace ANSI codes with corresponding HTML tags | |
let htmlText = ansiText; | |
Object.keys(ansiStyles).forEach(ansiCode => { | |
const htmlTag = ansiStyles[ansiCode]; | |
const regex = new RegExp(ansiCode.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'); // Escape special characters | |
htmlText = htmlText.replace(regex, htmlTag); | |
}); | |
// Replace newlines with <br> tags to preserve the formatting | |
htmlText = htmlText.replace(/\n/g, '<br>'); | |
return htmlText; | |
} | |
window.onload = function() { | |
const ansiContent = ` | |
[1;32mFY25 [1;37m| [1;34mQ3 [1;37m| [1;33mJan 26 [1;37mto [1;33mApr 29 [0;35m2025[0m | |
[1;32mFY25 [1;37m| [1;34mQ4 [1;37m| [1;33mApr 30 [1;37mto [1;33mJul 26 [0;35m2025[0m | |
[1;31mFY26 [1;37m| [1;35mQ1 [1;37m| [1;33mJul 27 [1;37mto [1;33mOct 26 [0;35m2025[0m | |
[1;31mFY26 [1;37m| [1;35mQ2 [1;37m| [1;33mOct 27 [1;37mto [1;33mJan 26 [0;36m2026[0m | |
[1;31mFY26 [1;37m| [1;35mQ3 [1;37m| [1;33mJan 27 [1;37mto [1;33mApr 26 [0;36m2026[0m | |
[1;31mFY26 [1;37m| [1;35mQ4 [1;37m| [1;33mApr 27 [1;37mto [1;33mJul 26 [0;36m2026[0m | |
[1;32mFY27 [1;37m| [1;34mQ1 [1;37m| [1;33mJul 27 [1;37mto [1;33mOct 26 [0;36m2026[0m | |
`; | |
const htmlContent = ansiToHtml(ansiContent); | |
document.getElementById("terminal-output").innerHTML = htmlContent; // Display result in the web page | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment