concept-collection / mdshare
mdshare / README.md
36 lines · 2.0 KBCodeBlameHistory
3A 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.
5**Live: <https://concept-collection.github.io/mdshare/>**
7## What it renders
9- LaTeX math, inline (`$...$`) and display (`$$...$$`), via remark-math and KaTeX
10- Fenced code blocks with per-language syntax highlighting (highlight.js) and a copy button
11- GitHub-flavored markdown: tables, task lists, strikethrough, footnotes, autolinks
12- Mermaid diagrams in ` ```mermaid ` fences (the mermaid library is loaded lazily, only when a document uses one)
14Raw 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.
16## How the URL encoding works
18The document is stored in the hash fragment as
20```
21#base64url( version byte + DEFLATE(utf8 text) )
22```
24The 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.
26A 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.
28## Development
30```bash
31npm install
32npm run dev # local dev server
33npm run build # typecheck + production build to dist/
34```
36Deployment to GitHub Pages is automatic on push to `main` via `.github/workflows/deploy.yml`.