konstantinosgkilas337 downloadsRenders inline SVG code fences as live graphics in Reading View and Live Preview mode.
An Obsidian plugin that renders inline SVG code fences as live graphics in both Reading View and Live Preview mode.
Paste raw SVG markup into a fenced code block and instantly see the rendered graphic — no file attachments needed.
svg code fences as live inline graphicsmain.js, manifest.json, and styles.css from the latest releasesvg-viewer inside your vault's .obsidian/plugins/ directorygit clone https://github.com/konstantinosGkilas/Obsidian-SVG-Viewer.git
cd Obsidian-SVG-Viewer
npm install
npm run build
Then copy main.js, manifest.json, and styles.css into your vault's .obsidian/plugins/svg-viewer/ directory.
Wrap SVG markup in a fenced code block with the svg language identifier:
```svg
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="40" fill="steelblue"/>
</svg>
```
The SVG renders as a live graphic. Interact with it:
| Setting | Default | Description |
|---|---|---|
| Block external resources | On | Strips external URLs (http://, https://) from SVG attributes |
| Show SVG badge | On | Displays a small "SVG" label below rendered blocks |
All SVG content is sanitized before it touches the DOM. The following are removed:
<script> elements<foreignObject> elements (can embed arbitrary HTML)on* event handler attributes (onclick, onload, onerror, etc.)javascript: URI schemes in href and src attributesdata:text/html and data:text/javascript URIsThe plugin never uses eval() or the Function() constructor.
npm install # install dependencies
npm run dev # start esbuild in watch mode
npm run build # production build
npm test # run unit tests
├── main.ts # Plugin entry point
├── src/
│ ├── sanitizer.ts # SVG sanitization (XSS prevention)
│ ├── validator.ts # SVG structural validation
│ ├── renderer.ts # Rendering pipeline and UI controls
│ └── settings.ts # Plugin settings tab
├── styles.css # Plugin styles
├── tests/
│ ├── sanitizer.test.ts
│ └── validator.test.ts
├── manifest.json
├── package.json
├── tsconfig.json
└── esbuild.config.mjs
git checkout -b feature/my-feature)npm test to verify all tests passnpm run build to verify the build succeeds