mirror of
https://github.com/addozhang/obsidian-mermaid-exporter.git
synced 2026-07-22 06:14:22 +00:00
No description
- Add vitest + jsdom + v8 coverage with a test/setup.ts that polyfills Obsidian-injected globals (Node.prototype.instanceOf, activeWindow, activeDocument, createEl) so the pure SVG helpers can run in isolation. - Export extractTextLines, fixDimensions, stripRootCss and replaceForeignObjects from src/svgToPng.ts (no behavior change) and cover them with 20 unit tests, plus one stubbed happy-path test for svgElementToPng. - Wire npm scripts (test, test:watch, test:coverage), enforce >=70% coverage thresholds on src/svgToPng.ts only, and run the suite in CI before the build step. Coverage: lines 91.3%, branches 71.15%, funcs 90% on src/svgToPng.ts. |
||
|---|---|---|
| .github/workflows | ||
| scripts/e2e | ||
| src | ||
| test | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| esbuild.config.mjs | ||
| LICENSE | ||
| manifest.json | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| styles.css | ||
| tsconfig.json | ||
| versions.json | ||
| vitest.config.ts | ||
Obsidian Mermaid Exporter
Export rendered mermaid diagrams as PNG images directly from Obsidian.
Features
- WYSIWYG Export — Exports the diagram exactly as Obsidian renders it, including your current theme
- Native Save Dialog — Uses the system file picker to save PNG files anywhere on disk
- Configurable Resolution — Scale factor from 1x to 4x (default 2x) for crisp high-DPI images
- Seamless UI — Export button appears next to the native "Edit this block" button on hover
- Works in Both Modes — Live Preview and Reading mode
Installation
From Community Plugins
- Open Settings → Community Plugins → Browse
- Search for Mermaid Exporter
- Click Install, then Enable
Manual Installation
- Download
main.js,manifest.json, andstyles.cssfrom the latest release - Create folder:
<vault>/.obsidian/plugins/mermaid-exporter/ - Copy the three files into that folder
- Reload Obsidian and enable the plugin in Settings → Community Plugins
Usage
- Create a mermaid code block in any note
- Hover over the rendered diagram
- Click the download button (appears top-right, next to the edit button)
- Choose a save location in the system dialog
- Done — PNG saved to disk
Settings
| Setting | Default | Description |
|---|---|---|
| Image scale | 2 | Resolution multiplier for exported PNG (1–4x) |
Requirements
- Obsidian ≥ 0.15.0
- Desktop only (Windows / macOS / Linux)
Development
git clone https://github.com/addozhang/obsidian-mermaid-exporter.git
cd obsidian-mermaid-exporter
npm install
npm run dev # watch mode
npm run build # production build
To test locally, symlink or copy main.js, manifest.json, and styles.css into your vault's .obsidian/plugins/mermaid-exporter/ directory.
Contributing
See CONTRIBUTING.md for development setup, bug reports, and pull request guidelines.
License
MIT — Addo Zhang