${body}`; const blob = new Blob([html], {type:'text/html'}); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'markdown-document.html'; a.click(); URL.revokeObjectURL(a.href); } function copyHtml(){ copyText(parseMd($('#input').value)); } $('#input').addEventListener('input', updatePreview); $('#input').addEventListener('keydown', e => { if(e.key === 'Tab'){ e.preventDefault(); const ta = e.target, start = ta.selectionStart; ta.value = ta.value.substring(0,start) + ' ' + ta.value.substring(ta.selectionEnd); ta.selectionStart = ta.selectionEnd = start + 2; updatePreview(); } }); $('#toolbar').innerHTML = ` `; // Restore draft try{ const saved = localStorage.getItem(STORAGE_KEY); if(saved){ $('#input').value = saved; } else { loadExample(); } }catch(e){ loadExample(); } updatePreview(); GZ.renderToolPage({ category: 'text', titleKey: 'toolTitle', descKey: 'toolDesc', howToSteps: ['step1','step2','step3','step4'], related: [ {icon:'📝', href:'/text/markdown.html', name:'Markdown Preview'}, {icon:'📄', href:'/text/markdown-to-html.html', name:'Markdown to HTML'}, {icon:'📊', href:'/text/markdown-table.html', name:'Markdown Table'}, {icon:'📚', href:'/text/markdown-cheatsheet.html', name:'Markdown Cheatsheet'}, ] });