A tiny (<50 lines) Node.js utility that delivers real-time rendering and preview for Markdown in the browser using Showdown. I built this tool to help me quickly preview and verify README formatting for my GitHub projects.
- Edit in any editor; updates appear instantly on save.
- Lightweight, with all the core logic contained in a small file (
srv.js), and a single dependency (Showdown) for Markdown to HTML conversion. - Uses Server-Sent Events (SSE) / EventSource to stream live updates to a static page.
pnpm/npm install # adds showdown then
pnpm/npm start
OR
chmod u+x srv.js
./srv.js
This starts a server on localhost port 8000 and watches readme.md for
changes. The port and file to watch can be configured via environment
variables.
FILE_TO_WATCH=readme.md
PORT=8000- This tool is for localhost use and supports only one SSE client at a time, so if you have multiple tabs open with the same URL, only the last one receives updates.
- GitHub Flavored Markdown is the default flavor. You can change this and
configure other options in
srv.js.
const conv = new md.Converter()
conv.setFlavor('github')
conv.setOption('simpleLineBreaks', false)See Showdown documentation for more details on flavors and configuration options.
