Update
Some checks failed
Deploy static content to Pages / deploy (push) Has been cancelled

This commit is contained in:
tyuXX 2026-11-08 00:48:45 +03:00
parent 8e5b906663
commit 54e01c7666
4 changed files with 502 additions and 366 deletions

View file

@ -327,16 +327,16 @@ ___
:coffee: :pizza: :cake: :apple:
## 12. Special Characters & Escaping
\* Escaped asterisk
\_ Escaped underscore
\# Escaped hash
\[ Escaped bracket
\] Escaped bracket
\` Escaped backtick
\( Escaped parenthesis
\) Escaped parenthesis
\~ Escaped tilde
\: Escaped colon
\\* Escaped asterisk
\\_ Escaped underscore
\\# Escaped hash
\\[ Escaped bracket
\\] Escaped bracket
\\\` Escaped backtick
\\( Escaped parenthesis
\\) Escaped parenthesis
\\~ Escaped tilde
\\: Escaped colon
## 13. HTML Support
<div style="color: blue;">
@ -387,14 +387,39 @@ That's all! This document showcases every feature supported by MDRender. Feel fr
togglePreviewBtn.textContent = preview.style.display === 'none' ? 'Show Preview' : 'Hide Preview';
});
function formatHtmlFallback(html) {
const voidTags = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']);
const tokens = html.split(/(<[^>]+>)/g).filter(t => t !== '');
const out = [];
let indent = 0;
const pad = () => ' '.repeat(Math.max(indent, 0));
for (const tok of tokens) {
if (tok.startsWith('</')) {
indent--;
out.push(pad() + tok);
} else if (tok.startsWith('<')) {
const m = tok.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);
const tag = m ? m[1].toLowerCase() : '';
out.push(pad() + tok);
if (!tok.endsWith('/>') && !voidTags.has(tag)) indent++;
} else {
const text = tok.trim();
if (text) out.push(pad() + text);
}
}
return out.join('\n');
}
formatHtmlBtn.addEventListener('click', () => {
const formatted = html_beautify(htmlOutput.textContent, {
indent_size: 2,
wrap_line_length: 80,
preserve_newlines: true,
max_preserve_newlines: 2
});
htmlOutput.textContent = formatted;
const raw = htmlOutput.textContent;
htmlOutput.textContent = typeof html_beautify === 'function'
? html_beautify(raw, {
indent_size: 2,
wrap_line_length: 80,
preserve_newlines: true,
max_preserve_newlines: 2
})
: formatHtmlFallback(raw);
});
exampleSelect.addEventListener('change', () => {