No description
Find a file
Addo.Zhang 2b9b32236c test: add vitest unit tests for svgToPng pure helpers (closes #3)
- 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.
2026-05-20 07:32:10 +08:00
.github/workflows test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00
scripts/e2e Scoped mermaid detection + popout support + CDP e2e suite (#7) 2026-05-19 09:41:50 +08:00
src test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00
test test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00
.gitignore test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00
CONTRIBUTING.md docs: add CONTRIBUTING.md and clean README placeholders 2026-05-17 10:26:32 +08:00
esbuild.config.mjs feat: initial release — mermaid diagram PNG exporter for Obsidian 2026-03-26 19:03:41 +08:00
LICENSE feat: initial release — mermaid diagram PNG exporter for Obsidian 2026-03-26 19:03:41 +08:00
manifest.json chore: bump version to 1.1.0 2026-05-19 09:42:42 +08:00
package-lock.json test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00
package.json test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00
README.md docs: add CONTRIBUTING.md and clean README placeholders 2026-05-17 10:26:32 +08:00
styles.css feat: initial release — mermaid diagram PNG exporter for Obsidian 2026-03-26 19:03:41 +08:00
tsconfig.json feat: initial release — mermaid diagram PNG exporter for Obsidian 2026-03-26 19:03:41 +08:00
versions.json chore: bump version to 1.1.0 2026-05-19 09:42:42 +08:00
vitest.config.ts test: add vitest unit tests for svgToPng pure helpers (closes #3) 2026-05-20 07:32:10 +08:00

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

  1. Open Settings → Community Plugins → Browse
  2. Search for Mermaid Exporter
  3. Click Install, then Enable

Manual Installation

  1. Download main.js, manifest.json, and styles.css from the latest release
  2. Create folder: <vault>/.obsidian/plugins/mermaid-exporter/
  3. Copy the three files into that folder
  4. Reload Obsidian and enable the plugin in Settings → Community Plugins

Usage

  1. Create a mermaid code block in any note
  2. Hover over the rendered diagram
  3. Click the download button (appears top-right, next to the edit button)
  4. Choose a save location in the system dialog
  5. Done — PNG saved to disk

Settings

Setting Default Description
Image scale 2 Resolution multiplier for exported PNG (14x)

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