concept-collection / mdshare
mdshare / README.md
2.0 KBPreviewCodeBlameHistoryRaw

mdshare#

A markdown editor whose document lives entirely in the URL. Type markdown on the left, see it rendered on the right, and share the page by copying the link: the text is compressed and encoded into the URL fragment, so there is no server, no account, and nothing is uploaded.

Live: https://concept-collection.github.io/mdshare/

What it renders#

Raw HTML in the document is deliberately rendered as text rather than passed through. Since any document can arrive via a shared link, HTML passthrough would let a link author run script in the viewer's browser.

How the URL encoding works#

The document is stored in the hash fragment as

#base64url( version byte + DEFLATE(utf8 text) )

The fragment is never sent to any server, and base64url needs no percent-escaping, so links survive copy and paste through chat clients and email. A one-byte version header leaves room to change the encoding later without breaking old links. Editing updates the URL in place (via replaceState, debounced) so the address bar always holds a shareable link; the length of the current URL is shown in the top bar.

A typical page of prose with a few equations compresses to a URL of roughly one to two thousand characters. Browsers handle URLs far longer than that, but some other software truncates very long links, so the length indicator is worth a glance before sharing a large document.

Development#

npm install
npm run dev     # local dev server
npm run build   # typecheck + production build to dist/

Deployment to GitHub Pages is automatic on push to main via .github/workflows/deploy.yml.