School ICT Self Study
📝 View in Your Language:

Markdown to PDF Converter

0 words0 chars

Markdown Quick Reference

# Heading 1
## Heading 2
**Bold**
*Italic*
[Link](url)
![Image](url)
- List item
1. Ordered
`code`
```code block```

PDF Preview

HTML Output

`); win.print(); win.close(); }// Word count function function updateWordCount() { const text = document.getElementById('markdown_content').value; const words = text.trim() ? text.trim().split(/\s+/).length : 0; const chars = text.length; document.getElementById('wordCount').textContent = `${words} words`; document.getElementById('charCount').textContent = `${chars} chars`; }// Enhanced text formatting function formatText(formatType) { const textarea = document.getElementById('markdown_content'); const start = textarea.selectionStart; const end = textarea.selectionEnd; const selectedText = textarea.value.substring(start, end); let formattedText = '';switch (formatType) { case 'bold': formattedText = `**${selectedText}**`; break; case 'italic': formattedText = `*${selectedText}*`; break; case 'heading1': formattedText = `# ${selectedText}`; break; case 'heading2': formattedText = `## ${selectedText}`; break; case 'link': const url = prompt("Enter the URL:", "https://"); if (url) formattedText = `[${selectedText}](${url})`; else return; break; case 'image': const imgUrl = prompt("Enter the image URL:", "https://"); if (imgUrl) formattedText = `![${selectedText}](${imgUrl})`; else return; break; case 'code': formattedText = "```\n" + selectedText + "\n```"; break; case 'blockquote': formattedText = `> ${selectedText}`; break; case 'unorderedList': formattedText = `- ${selectedText}`; break; case 'orderedList': formattedText = `1. ${selectedText}`; break; case 'table': formattedText = `| Header 1 | Header 2 |\n|----------|----------|\n| ${selectedText} | Data |`; break; case 'hr': formattedText = `---\n${selectedText}`; break; }textarea.value = textarea.value.substring(0, start) + formattedText + textarea.value.substring(end); textarea.focus(); updatePreview(); updateWordCount(); }// File import/export functions function importFile() { document.getElementById('fileInput').click(); }function handleFileSelect(event) { const file = event.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function(e) { document.getElementById('markdown_content').value = e.target.result; updatePreview(); updateWordCount(); }; reader.readAsText(file); } }function exportMarkdown() { const content = document.getElementById('markdown_content').value; const blob = new Blob([content], { type: 'text/markdown' }); saveAs(blob, `document_${new Date().toISOString().slice(0, 10)}.md`); }// Template insertion function insertTemplate() { const template = `# Document Title## Introduction Welcome to your new document! This is a **template** with common markdown elements.## Features - **Bold text** and *italic text* - Lists and organized content - Code examples: \`console.log("Hello")\` - [Links to resources](https://example.com)## Code Block \`\`\`javascript function example() { return "This is a code block"; } \`\`\`## Table Example | Header 1 | Header 2 | |----------|----------| | Data 1 | Data 2 |---*Happy writing!*`;document.getElementById('markdown_content').value = template; updatePreview(); updateWordCount(); }// Clear all content function clearAll() { if (confirm('Are you sure you want to clear all content?')) { document.getElementById('markdown_content').value = ''; updatePreview(); updateWordCount(); } }// Toggle editor collapse function toggleCollapse() { const textarea = document.getElementById('markdown_content'); const icon = document.getElementById('collapseIcon'); if (textarea.style.height === '100px') { textarea.style.height = ''; icon.textContent = '⬆️'; } else { textarea.style.height = '100px'; icon.textContent = '⬇️'; } }// Toggle text wrapping let wrapEnabled = true; function toggleWrap() { const textarea = document.getElementById('markdown_content'); const wrapText = document.getElementById('wrapText'); const wrapIcon = document.getElementById('wrapIcon'); wrapEnabled = !wrapEnabled; textarea.style.whiteSpace = wrapEnabled ? 'pre-wrap' : 'pre'; wrapText.textContent = wrapEnabled ? 'Wrap' : 'No Wrap'; wrapIcon.textContent = wrapEnabled ? '🔧' : '⛓️'; }// Copy text to clipboard function copyText() { const textarea = document.getElementById('markdown_content'); navigator.clipboard.writeText(textarea.value).then(() => { // Show temporary feedback const originalText = textarea.placeholder; textarea.placeholder = '✓ Copied to clipboard!'; setTimeout(() => { textarea.placeholder = originalText; }, 2000); }); }// Initialize window.onload = function() { updatePreview(); updateWordCount(); };
Select Language:
Select Font Size: