Syntax Highlighting tool, Markdown guide, unread share badge, Open in menu

- Syntax Highlighting (/syntax): highlight.js tokens rendered with VS Code
  (Dark/Light Modern, One Dark Pro, Monokai, Dracula, GitHub) and Android
  Studio (Darcula, Dark, IntelliJ Light) colors; copy as rich text (VS Code
  clipboard HTML), download RTF, share. Format via Prettier/sql-formatter
  (lazy-loaded), the JSON printer, or built-in whitespace-only formatters
  for brace languages, Python and XML.
- Markdown: Guide dialog, source next to rendered output, with Insert.
- Pastes created by Share count as unread on the Pastebin nav badge.
- Paste view: Open in menu built from registry opensPaste tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-02 00:30:13 -08:00
parent f4232ef9b5
commit dc2b12a3c6
37 changed files with 3704 additions and 27 deletions

View file

@ -14,6 +14,10 @@ See `README.md` for what this is and how it's deployed. This file is how to exte
2. **Register it** in `app/static/js/registry.js` (id, name, path, category, icon, description,
`load`). The sidebar, home grid, `/`-search and router all come from that list. Add a new
category to `CATEGORY_ORDER` if it should not sort last.
Optional: `opensPaste: true` if the tool loads `?paste=<id>` (it then shows in a paste's
"Open in" menu; call `markRead(id)` from `paste-state.js` when it does, and don't overwrite the
local draft), and `badge: () => number` for a count on its nav item (dispatch `tools:badges`
on `window` when it changes). Share buttons use `createPaste(text, { share: true })`.
3. **Server side, only if needed:** add `app/tools/<id>.py` exposing `router` (a FastAPI
`APIRouter`) with routes under `/api/<id>/…`, and optional `async startup()`/`shutdown()`.
`main.py` mounts every module in `tools/` automatically. Persistent files go under
@ -27,5 +31,14 @@ See `README.md` for what this is and how it's deployed. This file is how to exte
- Persist per-browser state with `store` from `ui.js` (namespaced, never throws), and flush
debounced saves on leave (`onLeave`, `debounce(...).flush`).
- Never render user content as HTML without DOMPurify (the Markdown preview) or `textContent`.
- `ui.js` has the shared pieces: `el`, `segmented`, `modal`, `dropdown`, `toast`, `copyText`,
`copyRich` (HTML + plain text), `downloadText`, `openTextFile`, `tabIndent`, `store`, `debounce`.
Note `el()` sets string values as attributes; assign `innerHTML` with `Object.assign`.
- Formatters in `code-format.js` must stay whitespace-only for the built-in languages. After
changing one, run the tests and also the formatter over a large set of real files, checking that
`squash(out) === squash(src)` and that formatting is idempotent (that's how the current rules
were validated: 1000+ Kotlin/Java/C/C++ files, 0 problems).
- Heavy libraries (Prettier, sql-formatter) are loaded with `import()` on first use only; keep
the initial page light (the server's upstream is slow).
- Run `node --test tests/` and check the page in a browser before deploying; `deploy.sh` refuses
to deploy if the tests fail.