Skip to content

feat: add modular renderer system for preview pane (#13)#42

Open
andrewhopper wants to merge 1 commit intomasterfrom
claude/issue-13-20260303-1116
Open

feat: add modular renderer system for preview pane (#13)#42
andrewhopper wants to merge 1 commit intomasterfrom
claude/issue-13-20260303-1116

Conversation

@andrewhopper
Copy link
Copy Markdown
Owner

Introduces a plugin-style RendererRegistry that replaces the monolithic switch statement in app.js. Each file type is now a self-contained renderer module in public/renderers/.

New renderers: JSON (interactive tree view), Mermaid diagrams, enhanced Markdown (with Mermaid code blocks), YAML, Python, HTML, React, SVG, and a catch-all text fallback.

Closes #13

Generated with Claude Code

Introduces a plugin-style RendererRegistry that replaces the monolithic
switch statement in app.js. Each file type is now a self-contained
renderer module in public/renderers/.

New renderers:
- registry.js     — central RendererRegistry (window.RendererRegistry)
- html-renderer.js      — sandboxed iframe for .html files
- react-renderer.js     — Babel JSX → ReactDOM render for .jsx files
- svg-renderer.js       — inline SVG with script-tag sanitisation
- json-renderer.js      — interactive collapsible tree view for .json
- mermaid-renderer.js   — Mermaid diagram rendering for .mmd/.mermaid files
- markdown-renderer.js  — marked.js + hljs; detects ```mermaid blocks
- python-renderer.js    — rich "click Run" preview for .py files
- yaml-renderer.js      — hljs-highlighted view for .yaml/.yml files
- text-renderer.js      — catch-all fallback (priority 0)

Adding a new renderer only requires:
1. Create public/renderers/<name>-renderer.js
2. Call RendererRegistry.register({ name, extensions, render })
3. Add a <script> tag in index.html

Also adds marked.js and Mermaid.js CDN imports, JSON tree viewer CSS,
and full Markdown body styles.

Co-authored-by: Andrew Hopper <andrewhopper@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add modular system for adding modules to render different types of context like json, mermaid, etc in the preview pane

1 participant