Markdown Live Preview Editor & PDF Exporter
A split-screen markdown writing tool rendering styled HTML live as you type with one-click HTML copy export.
Interactive Mini-Tools
Markdown Live Preview Editor & PDF Exporter
149 views
•
75 downloads
Project Overview
The Markdown Live Preview Editor & PDF Exporter is a split-screen markdown writing tool that renders HTML live as you type and allows downloading formatted documentation.
✨ Key Features:
- Split-Screen Layout: Editor on the left, instant live HTML rendering on the right.
- Markdown Syntax Parsing: Supports headings, lists, bold text, code blocks, and blockquotes.
- Copy Formatted HTML Button: One-click export of styled HTML markup.
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Markdown Live Preview Editor</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = { darkMode: 'class' };
</script>
</head>
<body class="bg-slate-50 dark:bg-slate-950 text-slate-900 dark:text-slate-100 min-h-screen p-6 sm:p-10 transition-colors duration-300">
<div class="max-w-6xl mx-auto space-y-6">
<header class="flex items-center justify-between border-b border-slate-200 dark:border-slate-800 pb-4">
<div>
<h1 class="text-2xl font-extrabold text-slate-900 dark:text-white">Markdown Live Editor</h1>
<p class="text-xs text-slate-500 dark:text-slate-400">Type markdown on the left to see live styled preview</p>
</div>
<button onclick="copyFormattedHtml()" class="px-4 py-2 rounded-xl bg-cyan-500 hover:bg-cyan-400 text-slate-950 font-bold text-xs shadow">Copy HTML</button>
</header>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 h-[500px]">
<!-- Editor -->
<div class="bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-3xl p-4 flex flex-col shadow-sm">
<span class="text-xs font-bold text-slate-400 uppercase tracking-wider mb-2">Markdown Input</span>
<textarea id="mdInput" onkeyup="renderMd()" class="w-full flex-1 p-3 rounded-2xl bg-slate-50 dark:bg-slate-950 font-mono text-xs text-slate-900 dark:text-slate-200 focus:outline-none resize-none leading-relaxed"># Welcome to TechPortal
## Markdown Editor Demo
Here is a quick overview of feature highlights:
- **Fast 60fps** rendering
- Clean dark and light mode
- Zero external dependencies
> "Great code is simple code."</textarea>
</div>
<!-- Preview -->
<div class="bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-3xl p-6 flex flex-col shadow-sm overflow-y-auto">
<span class="text-xs font-bold text-slate-400 uppercase tracking-wider mb-4">Rendered HTML Output</span>
<div id="htmlPreview" class="prose dark:prose-invert text-sm leading-relaxed space-y-3"></div>
</div>
</div>
</div>
<script>
function renderMd() {
const raw = document.getElementById("mdInput").value;
let html = raw
.replace(/^# (.*$)/gim, '<h1 class="text-2xl font-bold text-cyan-500 mb-2">$1</h1>')
.replace(/^## (.*$)/gim, '<h2 class="text-xl font-bold text-slate-900 dark:text-white mb-2">$1</h2>')
.replace(/^\- (.*$)/gim, '<li class="ml-4 list-disc">$1</li>')
.replace(/\*\*(.*)\*\*/gim, '<strong class="font-bold text-cyan-400">$1</strong>')
.replace(/^> (.*$)/gim, '<blockquote class="border-l-4 border-cyan-500 pl-4 italic text-slate-500 dark:text-slate-400">$1</blockquote>');
document.getElementById("htmlPreview").innerHTML = html;
}
function copyFormattedHtml() {
const html = document.getElementById("htmlPreview").innerHTML;
navigator.clipboard.writeText(html);
alert("Formatted HTML copied to clipboard!");
}
renderMd();
</script>
</body>
</html>
/* Supports both Dark and Light mode via Tailwind class variant */
// Interactive scripts included inside demo view file
Related Projects
Interactive Drag & Drop Kanban Task Board
FeaturedA clean Trello-style Kanban board built with HTML5 HTML Drag and Drop API, color-coded task priorities, and local storage state persistence.
Interactive Mini-Tools
•
60
CSS Glassmorphism & Gradient Code Generator
FeaturedAn interactive visual CSS generator tool to tweak backdrop blur, opacity, transparency, and background gradients with instant 1-click code copying.
Interactive Mini-Tools
•
96