JavaScript editor/viewer for Markdown and HTML with live preview, bidirectional editing, and rich content support.
Live Demo | Documentation | API Reference | Local Demo
SquibView renders Markdown (or HTML) with live preview and allows editing in both source and rendered views. Changes sync automatically between views.
Key Capabilities:
Supported Content:
<!-- SquibView CSS --><linkrel="stylesheet"href="https://unpkg.com/squibview/dist/squibview.min.css"><!-- Optional: Only needed for syntax highlighting and diagrams --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script><scriptsrc="https://unpkg.com/mermaid/dist/mermaid.min.js"></script><scripttype="module">// SquibView ESM build - markdown-it is now bundled! No import maps needed!importSquibViewfrom'https://unpkg.com/squibview/dist/squibview.esm.min.js';
const editor = newSquibView('#editor', {
initialContent: '# Hello\nStart typing **markdown**...'
});
</script><divid="editor"></div>
New in v1.0.15: Default builds now include markdown-it bundled. No more import map errors! For advanced users who want to manage dependencies, use the
-lean
builds.
npm install squibview
importSquibViewfrom'squibview';
const editor = newSquibView('#editor');
SquibView includes a command line tool (squibv
) for converting markdown/HTML files to standalone HTML pages.
# Convert markdown to HTML page
npx squibv document.md
# Watch mode - rebuilds on file changes
npx squibv document.md --watch
# Bundle for offline use (embeds all assets)
npx squibv document.md --bundle-offline
editor.setView('split'); // Side-by-side editing (default)
editor.setView('src'); // Source only
editor.setView('html'); // Rendered only
// Set markdown content
editor.setContent('# My Document\n\nEdit this text...', 'md');
// Get current contentconst markdown = editor.getContent();
const html = editor.getRenderedHTML();
editor.revisionUndo();
editor.revisionRedo();
// Compare revisions (v1.0.13+)const diffHTML = editor.getSourceDiffHTML({ fromIndex: 0, toIndex: 2 });
const inlineDiff = editor.getSourceDiffInline(); // Blue additions, red deletions
editor.copySource(); // Copy markdown to clipboard
editor.copyHTML(); // Copy rendered HTML
editor.exportHTML(); // Download as file
Live Examples (GitHub Pages)
Local Examples (after cloning repo)
Online Documentation
Local Documentation (after cloning)
Build | When to Use | Size | Whatโs Included |
---|---|---|---|
squibview.esm.min.js | Modern bundlers (webpack, vite) | ~240KB | markdown-it bundled |
squibview.esm-lean.min.js | When you manage markdown-it | ~140KB | No dependencies |
squibview.umd.min.js | Script tags | ~250KB | markdown-it bundled |
squibview.umd-lean.min.js | Legacy with own dependencies | ~140KB | No dependencies |
squibview.standalone.umd.min.js | Zero setup needed | ~3.7MB | Everything bundled |
v1.0.15 Change: Default builds now include markdown-it, diff-match-patch, and tiny-emitter bundled. Use
-lean
builds if you need the old behavior.
BSD-2-Clause. See LICENSE.