How mikevetkin/obsidian-tengwar works
Purpose and Host Integration
This is an Obsidian plugin that renders fenced Markdown code blocks containing Tengwar text. It supports configurable block keywords, per-block font variants, and ISO 8859-1 or ConScript Unicode Registry (CSUR) encodings. The plugin entry point is main.ts; Obsidian loads it according to manifest.json.
Plugin Lifecycle and Rendering Registration
main.ts owns plugin startup, settings loading, registration of the settings tab, and registration/refresh of Tengwar Markdown code-block processors. Processor registration is separated so changes to settings can replace active language handlers without restarting the app:
• main.ts
• feature/tengwar/domain/lib/refresh-processors.ts
• feature/tengwar/domain/lib/teng-processor.ts
Tengwar Code-Block Processing
The rendering pipeline receives code-block source text and its declared language identifier (for example, teng or teng-artano). It identifies the base keyword and optional font suffix, resolves rendering behavior, preserves intended line breaks, and emits rendered Tengwar content into Obsidian’s preview DOM. This boundary is preview rendering; editing-mode rendering is explicitly not the primary supported path.
• feature/tengwar/domain/lib/teng-processor.ts
• feature/tengwar/domain/lib/get-text-with-breaks.ts
• feature/tengwar/domain/lib/get-tengwar-font-class.ts
Encoding Resolution
The domain model supports two character representations: ASCII/ISO 8859-1-oriented Tengwar text and CSUR Unicode text. Encoding selection is centralized rather than embedded in UI or processor registration, allowing rendering to select the appropriate font/class treatment from detected or configured text characteristics.
• feature/tengwar/domain/entity/encoding.ts
• feature/tengwar/domain/lib/get-encoding.ts
• feature/tengwar/domain/entity/csur-tengwar.ts
Language/Keyword Routing
Configured processor languages determine which fenced-block identifiers Obsidian recognizes. The system builds a list from the user-selected primary keyword plus supported font suffix variants, then registers processors for that list. This lets users rename the base keyword (such as from teng to elfish) while retaining per-font syntax.
• feature/tengwar/domain/entity/processor-languages.ts
• feature/tengwar/domain/lib/make-processor-languages-list.ts
• feature/tengwar/domain/lib/refresh-processors.ts
Settings Domain and UI
Settings are modeled as a domain entity with defaults and font option entities, then exposed through an Obsidian settings tab. Settings govern the default font and processor keyword; updates feed back into processor refresh/registration.
• feature/settings/domain/entity/plugin-settings.ts
• feature/settings/domain/entity/default-plugin-settings.ts
• feature/settings/ui/settings-tab.ts
Font Taxonomy and Styling Boundary
Font choices are represented as separate entities for ASCII, CSUR, and Tengwar font definitions. Runtime code maps a chosen/inferred font to CSS classes; stylesheet assets provide the actual visual rendering. This keeps font selection logic distinct from DOM styling and browser font rendering.
• feature/settings/domain/entity/ascii-font.ts
• feature/settings/domain/entity/csur-font.ts
• feature/settings/domain/entity/tengwar-font.ts
• styles.css
Runtime and Delivery
The plugin is TypeScript compiled/bundled with esbuild for the Obsidian desktop/mobile runtime. It depends on Obsidian’s plugin API for lifecycle, settings persistence, and Markdown post-processing; no backend or external runtime service is indicated. Release automation publishes versioned plugin artifacts through GitHub Actions.
• esbuild.config.mjs
• package.json
• .github/workflows/release.yml
Main entry points: main.ts Plugin entry point · refresh-processors.ts Processor refresh · teng-processor.ts Tengwar processor · get-tengwar-font-class.ts Font class resolver
Components 18
Obsidian host
- Plugin manifest
manifest.json - Obsidian API · Provides lifecycle, persistence, settings UI, and Markdown processors.
Plugin runtime
- Plugin entry point · Loads settings, registers the tab, and refreshes processors.
main.ts
Tengwar rendering
- Processor refresh · Replaces active language handlers when settings change.
feature/tengwar/domain/lib/refresh-processors.ts - Processor languages · Builds base keyword and per-font language variants.
feature/tengwar/domain/lib/make-processor-languages-list.ts - Processor language model
feature/tengwar/domain/entity/processor-languages.ts - Tengwar processor · Processes preview-mode fenced Tengwar blocks.
feature/tengwar/domain/lib/teng-processor.ts - Line break preservation
feature/tengwar/domain/lib/get-text-with-breaks.ts - Font class resolver · Maps selected encoding and font to DOM CSS classes.
feature/tengwar/domain/lib/get-tengwar-font-class.ts - Encoding resolver · Selects ISO 8859-1-oriented or CSUR treatment.
feature/tengwar/domain/lib/get-encoding.ts - Encoding and CSUR model
feature/tengwar/domain/entity/encoding.ts
Settings and fonts
- Settings tab · Edits the default font and processor keyword.
feature/settings/ui/settings-tab.ts - Plugin settings · Defines persisted settings and defaults.
feature/settings/domain/entity/plugin-settings.ts - Font taxonomy · Defines ASCII, CSUR, and Tengwar font choices.
feature/settings/domain/entity/tengwar-font.ts - Tengwar styles · Supplies font classes and visual rendering.
styles.css
Build and release
- esbuild bundle · Bundles the plugin for Obsidian desktop and mobile.
esbuild.config.mjs - Package definition
package.json - Release workflow · Publishes versioned plugin artifacts.
.github/workflows/release.yml
Connections 20
- Plugin manifest → Plugin entry point: loads
- Obsidian API → Plugin entry point: hosts
- Plugin entry point → Plugin settings: loads and saves
- Plugin entry point → Settings tab: registers
- Plugin entry point → Processor refresh: refreshes
- Settings tab → Plugin settings: edits
- Settings tab → Processor refresh: on update
- Processor refresh → Processor languages: gets handlers for
- Processor languages → Processor language model: uses
- Processor refresh → Obsidian API: registers processors
- Processor refresh → Tengwar processor: installs
- Tengwar processor → Line break preservation: preserves
- Tengwar processor → Encoding resolver: resolves
- Tengwar processor → Font class resolver: applies
- Encoding resolver → Encoding and CSUR model: uses
- Font class resolver → Font taxonomy: selects from
- Font class resolver → Tengwar styles: emits classes for
- Package definition → esbuild bundle: configures
- esbuild bundle → Plugin entry point: bundles
- Release workflow → Package definition: versions and publishes