# SVG Viewer
An [Obsidian](https://obsidian.md) 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.
## Features
- Renders `svg` code fences as live inline graphics
- Works in both Reading View and Live Preview
- **Security-first**: all SVG is sanitized before rendering (scripts, event handlers, and dangerous URIs are stripped)
- Click a rendered block to view the raw SVG source; click outside to return to the graphic
- Copy SVG source to clipboard with one click
- Optional "SVG" badge label on rendered blocks
- Configurable external resource blocking
- Supports dark and light themes
- Zero runtime dependencies
## Installation
### Manual
1. Download `main.js`, `manifest.json`, and `styles.css` from the [latest release](https://github.com/konstantinosGkilas/Obsidian-SVG-Viewer/releases)
2. Create a folder called `svg-viewer` inside your vault's `.obsidian/plugins/` directory
3. Copy the three files into that folder
4. Open Obsidian Settings → Community Plugins → Enable "SVG Viewer"
### From Source
```bash
git 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.
## Usage
Wrap SVG markup in a fenced code block with the `svg` language identifier:
````markdown
```svg
```
````
The SVG renders as a live graphic. Interact with it:
- **Click the block** — switches to the raw SVG source view
- **Click outside** — switches back to the rendered graphic
- **Hover** — reveals a copy button in the top-right corner
## Settings
| 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 |
## Security
All SVG content is sanitized before it touches the DOM. The following are removed:
- `