Skip to content

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.

Notifications You must be signed in to change notification settings

v7e5/markdown-live-preview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown Live Preview

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.

demo

Features

  • 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.

Usage

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

Notes

  • 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.

About

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.

Topics

Resources

Stars

Watchers

Forks