How joethei/obsidian-plantuml works
Project type and purpose
• This is an Obsidian “Community Plugin” that adds PlantUML rendering support to the Obsidian note-taking app.
• It processes fenced code blocks (plantuml, plantuml-svg, plantuml-ascii) and renders them either via an online PlantUML server or a local JAR.
File structure
• Top-level config & metadata: manifest.json, package.json, .github/workflows, esbuild.config.mjs, tsconfig.json.
• Core plugin code in src/:
• main.ts – plugin activation, registration of code block processor
• settings.ts & const.ts – user‐configurable settings (server URL, local JAR path, output format)
• processors/ – several processor implementations (debounced, local, server)
• functions.ts & processors/processor.ts – shared utilities, base interfaces
• Static styling: styles.css
• Version management: versions.json
README for additional insights
• Describes two rendering modes: remote server vs. local JAR.
• Mentions support for three languages/formats: PNG, SVG, ASCII.
• Notes linking syntax and caveats for local rendering.
a. Main components
• Obsidian Host (Electron app)
• PlantUML Plugin
• Activation & lifecycle (main.ts)
• Settings UI
• Code block processor manager
• Rendering pipeline (chooses server vs. local)
• PumlView renderer
• External PlantUML Renderer
• Remote PlantUML Server (HTTP endpoint)
• Local PlantUML JAR (spawned Java process)
• Vault (filesystem where notes live)
b. Relationships & interactions
1. User writes fenced code in a note → Obsidian triggers plugin hook.
2. Plugin’s processor reads code block → forwards to either serverProcessor or localProcessor.
3. serverProcessor: HTTP POST to PlantUML server → receives PNG/SVG → embed.
4. localProcessor: spawn java -jar plantuml.jar with inputs → capture stdout.
5. embed.ts / PumlView.ts injects rendered output back into the note view.
6. Settings UI allows switching endpoints, formats; settings.ts persists to Obsidian.
c. Architectural patterns & principles
• Plugin modularization: separation of concerns between processors, view, embed logic.
• Strategy pattern for rendering: interchangeable server vs. local processors.
• Debouncing for performance: debouncedProcessors.ts to avoid excessive calls on rapid changes.
• Use of Obsidian’s Plugin API to hook into lifecycle and renderer.
d. Relevant technologies/frameworks
• TypeScript, Obsidian Plugin API
• esbuild for bundling
• HTTP fetch API (for server requests)
• Node.js child_process (for local JAR)
• CSS for styling injected views
Detailed capture of essential elements
• Break the plugin into:
• Entry point (main.ts)
• Renderer manager (processors/*)
• View layer (PumlView.ts)
• Embedding logic (embed.ts)
• Settings & constants
• Optional paths (SVG vs. ASCII vs. PNG, server vs. local).