|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Display Text as HTML</title>
|
|
<script>
|
|
|
|
function handleFileSelect(event) {
|
|
const file = event.target.files[0];
|
|
let errorCode = "0x00000000";
|
|
if (!file) {
|
|
errorCode = "0x00000111";
|
|
alert('No TXT file selected. EC: ' + errorCode);
|
|
return;
|
|
}
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
const text = e.target.result;
|
|
const lines = text.split('\n');
|
|
let htmlContent = '';
|
|
|
|
lines.forEach(line => {
|
|
line = line.trim();
|
|
|
|
if (line.startsWith('!h1-')) {
|
|
const headerText = line.substring(4).trim();
|
|
htmlContent += `<h1>${headerText}</h1>`;
|
|
} else if (line.startsWith('!h2-')) {
|
|
const headerText = line.substring(4).trim();
|
|
htmlContent += `<h2>${headerText}</h2>`;
|
|
} else if (line.startsWith('!h3-')) {
|
|
const headerText = line.substring(4).trim();
|
|
htmlContent += `<h3>${headerText}</h3>`;
|
|
} else if (line.startsWith('!h4-')) {
|
|
const headerText = line.substring(4).trim();
|
|
htmlContent += `<h4>${headerText}</h4>`;
|
|
} else if (line.startsWith('!h5-')) {
|
|
const headerText = line.substring(4).trim();
|
|
htmlContent += `<h5>${headerText}</h5>`;
|
|
} else if (line.startsWith('!h6-')) {
|
|
const headerText = line.substring(4).trim();
|
|
htmlContent += `<h6>${headerText}</h6>`;
|
|
} else if (line.startsWith('!font=')) {
|
|
const fontInfo = line.substring(6).trim();
|
|
const [fontName, text] = fontInfo.split('-', 2).map(part => part.trim());
|
|
htmlContent += `<p style="font-family: ${fontName};">${text}</p>`;
|
|
} else {
|
|
htmlContent += `<p>${line}</p>`;
|
|
}
|
|
});
|
|
|
|
|
|
document.getElementById('output').innerHTML = htmlContent;
|
|
};
|
|
|
|
reader.readAsText(file);
|
|
}
|
|
|
|
|
|
function saveAsNMSK() {
|
|
const content = document.getElementById('output').innerHTML;
|
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
const fileName = 'generated_content.nmsk';
|
|
|
|
const a = document.createElement('a');
|
|
a.href = URL.createObjectURL(blob);
|
|
a.download = fileName;
|
|
a.click();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h2>HTML Header/Font Editor!</h2>
|
|
<input type="file" accept=".txt" onchange="handleFileSelect(event)">
|
|
<div id="output"></div>
|
|
<h1>Controls:</h1>
|
|
<p>!h1-</p>
|
|
<p>!h2-</p>
|
|
<p>!h3-</p>
|
|
<p>!h4-</p>
|
|
<p>!h5-</p>
|
|
<p>!h6-</p>
|
|
<p>!font=[fontname]-</p>
|
|
|
|
|
|
<button onclick="saveAsNMSK()">Save as .nmsk...</button>
|
|
</body>
|
|
</html>
|
|
|