feat: add modular renderer system for preview pane (#13)#42
Open
andrewhopper wants to merge 1 commit intomasterfrom
Open
feat: add modular renderer system for preview pane (#13)#42andrewhopper wants to merge 1 commit intomasterfrom
andrewhopper wants to merge 1 commit intomasterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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